I tried to get this working in C# starting out with a Websharper 4 Client-Server Application.

To client.cs I added

1
2
using WebSharper.SlickGrid.Slick;
using WebSharper.SlickGrid.Slick.Data;

and this class:

1
2
3
4
5
6
7
8
    [JavaScript]
    public class Data
    {
        [Name("id")]
        public string Id { get; set; }
        public string ColA { get; set; }
        public string ColB { get; set; }
    }

Then in I added in Main:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
        public static IControlBody Main()
        {
            var col = new[]
            {
                new Column<Data>("ColA", "Col A") {Field = "ColA"},
                new Column<Data>("ColB", "Col B") {Field = "ColB"}
            };

            var dvvo = new DataViewOptions<Data>();
            var data = new DataView<Data>(dvvo);

            var datas = new []
            {
                new Data {Id = "1", ColA = "Test A", ColB = "Test B"},
                new Data {Id = "2", ColA = "Test A", ColB = "Test B"}
            };

            data.BeginUpdate();
            data.SetItems(datas, "$Id");
            data.EndUpdate();
             
            ....

Despite the Name-attribute I have to specify the id-column explicitly:

data.SetItems(datas, "$Id")

including the $, otherwise the table fails to load:

Uncaught Each data element must implement a unique 'id' property

Is this the proper way to implement a SlickGrid-Table in C#?

EDIT:

For the data to show up the Field needs $-prefixing as well:

1
2
3
4
5
6
7





By on 7/25/2018 12:06 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper