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

2 posts, 1 answers
  1. Joshua
    Joshua avatar
    4 posts
    Member since:
    Aug 2016

    Posted 16 Nov 2016 Link to this post

    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

  2. Answer
    Rosen
    Admin
    Rosen avatar
    3246 posts

    Posted 18 Nov 2016 Link to this post

    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.
Back to Top