MVVM Grid and toolbar

4 posts, 1 answers
  1. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 13 Jun 2013 Link to this post

    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>
  2. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 14 Jun 2013 Link to this post

    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.}
  3. Kendo UI is VS 2017 Ready
  4. Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 14 Jun 2013 Link to this post

    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.}
  5. Answer
    Dr.YSG
    Dr.YSG avatar
    210 posts
    Member since:
    Dec 2009

    Posted 14 Jun 2013 Link to this post

    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.

Back to Top
Kendo UI is VS 2017 Ready