Search code examples
kendo-uikendo-gridkendo-datasource

Kendo Ui grid is not updating when changing schema to use data instead of model


This example from kendo's site which I clone to jsfiddle works just fine: http://jsfiddle.net/destan/xXc82/

But when I change this part:

schema: {
  model: {
    id: "ProductID",
    fields: {
      ProductID: { editable: false, nullable: true },
      ProductName: { validation: { required: true } },
      UnitPrice: { type: "number", validation: { required: true, min: 1} },
      Discontinued: { type: "boolean" },
      UnitsInStock: { type: "number", validation: { min: 0, required: true } }
    }
  }
}

like this: (updated fiddle: http://jsfiddle.net/destan/Wqd4t/1/)

schema: {
  data: function(response){
    return response
  }
}

then clicking the save button after editing rows won't update the grid although the saveChanges event is triggered.

You can observe on network tab of dev console that in first example after editing clicking save button cause an request to the server while in second example no request is made.

any idea why?


Solution

  • The problem with your code is you not defined schema.model.id which datasource needs it when you create,update,delete. so corrected code is:

    schema: {
      model: {
        id: "ProductID"
      },
      data: function(response){
        return response;
      }
    }
    

    fiddle: http://jsfiddle.net/Wqd4t/2/

    references: kendo.data.DataSource , kendo.data.Model