This is a migrated thread and some comments may be shown as answers.

MVVM Grid and toolbar

3 Answers 129 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Dr.YSG
Top achievements
Rank 2
Dr.YSG asked on 13 Jun 2013, 09:00 PM
I have an kendo.Grid that is using initializing from JSON (MVVM paradigm). It all works fine until made it editable and added a toolbar. The destroy functions are working just fine.

But the SaveChanges in the toolbar does not seem to do anything. Why do I say that? Because if I hit [Cancel Changes] button in the toolbar, all rows are deleted, and I am left with an empty Grid (only headers).
<div id="layerTable"
    class="Part"
    data-role="grid"
    data-column-menu="true"
    data-filterable="true"
    data-sortable="true"
    data-scrollable="false"
    data-resizable="true"
    data-reorderable="true"
    data-groupable="true"
    data-editable="{confirmation: false}"
    data-bind="source: LayerTable"
    data-toolbar='["save","cancel"]'
    data-columns='[
        "Class",
        "Type",
        "FileCount",
        {field: "Size",
         format: "{0:n3} MB",
        },
        {field: "Date",
         format: "{0:F}" },
        "Path",
        {command: "destroy"},
    ]'>
</div>

3 Answers, 1 is accepted

Sort by
0
Dr.YSG
Top achievements
Rank 2
answered on 14 Jun 2013, 01:45 PM
Some Additional information. The DataSource is being "source bound" from the MVVM. The MVVM has a JSON array for the source (which Grid turns into a Kendo.DataSource). I suspect this might be some of the issue.

Here is what the JSON for the data looks like:

01.{
02. "Layers" : [
03.  {
04.   "Class" : "BASE",
05.   "Date" : "\/Date(1370539274583-0400)\/",
06.   "FileCount" : 43691,
07.   "Path" : "http:\/\/ylocalhost\/BaseMaps\/DRAPER-Little-BlueMarble",
08.   "Size" : 14.28853607177734,
09.   "Type" : "Little-BlueMarble"
10.  },
11.  {
12.   "Class" : "BASE",
13.   "Date" : "\/Date(1370539006327-0400)\/",
14.   "FileCount" : 43691,
15.   "Path" : "http:\/\/slocalhost\/BaseMaps\/NASA-BlueMarble",
16.   "Size" : 184.28853607177734,
17.   "Type" : "NASA-BlueMarble"
18.  },
19.  {
20.   "Class" : "OVERLAYS",
21.   "Date" : "\/Date(1370538407040-0400)\/",
22.   "FileCount" : 121,
23.   "Path" : "http:\/\/localhost\/TileSetJobs\/CIB10",
24.   "Size" : 3.0540943145751953,
25.   "Type" : "CIB10"
26.  }
27. ]
28.}
0
Dr.YSG
Top achievements
Rank 2
answered on 14 Jun 2013, 01:46 PM
The DataSource is being "source bound" from the MVVM. The MVVM has a JSON array for the source (which Grid turns into a Kendo.DataSource). I suspect this might be some of the issue

Here is what the JSON for the data looks like:

01.{
02. "Layers" : [
03.  {
04.   "Class" : "BASE",
05.   "Date" : "\/Date(1370539274583-0400)\/",
06.   "FileCount" : 43691,
07.   "Path" : "http:\/\/ylocalhost\/BaseMaps\/DRAPER-Little-BlueMarble",
08.   "Size" : 14.28853607177734,
09.   "Type" : "Little-BlueMarble"
10.  },
11.  {
12.   "Class" : "BASE",
13.   "Date" : "\/Date(1370539006327-0400)\/",
14.   "FileCount" : 43691,
15.   "Path" : "http:\/\/slocalhost\/BaseMaps\/NASA-BlueMarble",
16.   "Size" : 184.28853607177734,
17.   "Type" : "NASA-BlueMarble"
18.  },
19.  {
20.   "Class" : "OVERLAYS",
21.   "Date" : "\/Date(1370538407040-0400)\/",
22.   "FileCount" : 121,
23.   "Path" : "http:\/\/localhost\/TileSetJobs\/CIB10",
24.   "Size" : 3.0540943145751953,
25.   "Type" : "CIB10"
26.  }
27. ]
28.}
0
Accepted
Dr.YSG
Top achievements
Rank 2
answered on 14 Jun 2013, 04:15 PM
I changed the KendoObservableObject (VM object) that the Grid shows from a JSON array (where I was trigger() the changes). To a DataSource, and it now works fine.

Tags
Grid
Asked by
Dr.YSG
Top achievements
Rank 2
Answers by
Dr.YSG
Top achievements
Rank 2
Share this question
or