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

What does the options.success and options.error message expect as an argument?

1 Answer 478 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Joshua
Top achievements
Rank 1
Joshua asked on 16 Nov 2016, 05:36 PM

I'm working with transports for remote data for the DataSource, and I have a question with what exactly Kendo is expecting to be passed to options.success and options.error. I see it's the result from the server, but what is that result supposed to be? For example, what does Kendo expect to be returned from the server in an update? http://docs.telerik.com/kendo-ui/api/javascript/data/datasource#configuration-transport.update

1 Answer, 1 is accepted

Sort by
1
Accepted
Rosen
Telerik team
answered on 18 Nov 2016, 07:46 AM

Hello Joshua,

The success callback expects an array or an object (which has array as a field) with structure described inside the DataSource.schema. By default the expected structure is array containing the data. 

Regarding the response for the update operation. It should have the same shape as the one described by the schema, however the `data` field should contain only the updated/edited records. This is mentioned here.

For example: 

var dataSource = new kendo.data.DataSource({
   transport: {
      read: function(options) {
          options.success({
             data: [ { id: 1, productName: "Product1" }, { id: 2, productName: "Product2" }],
             total: 2
          });
      },
       update: function(options) {
          options.success({
             data: [ { id: 1, productName: "ChangeName" }] // if we have changed the product with id=1
          });
      },
   },
   schema: {
      data: "data",
      total: "total",
      model: {
         id: "id"
      }
   }
});



Regards,
Rosen
Telerik by Progress
Kendo UI is ready for Visual Studio 2017 RC! Learn more.
Tags
Data Source
Asked by
Joshua
Top achievements
Rank 1
Answers by
Rosen
Telerik team
Share this question
or