transport.submit Function

A function that will handle create, update and delete operations in a single batch when custom transport is used, i.e. the transport.read is defined as a function.

The transport.create, transport.update and transport.delete operations will not be executed in this case.

This function will only be invoked when the DataSource is in batch mode.

Parameters

e.data Object

An object containing the created (e.data.created), updated (e.data.updated), and destroyed (e.data.destroyed) items.

e.success Function

A callback that should be called for each operation with two parameters - items and operation. See example below.

e.error Function

A callback that should be called in case of failure of any of the operations.

Example - declare transport submit function
  <script>
      var dataSource = new kendo.data.DataSource({
        transport: {
          read:  function(options){
            $.ajax({
              url: "https://demos.telerik.com/kendo-ui/service/products",
              dataType: "jsonp",
              success: function(result) {
                options.success(result);
              },
              error: function(result) {
                options.error(result);
              }
            });
          },
          submit: function(e) {
            var data = e.data;
            console.log(data);

            // send batch update to desired URL, then notify success/error

            e.success(data.updated,"update");
            e.success(data.created,"create");
            e.success(data.destroyed,"destroy");
            e.error(null, "customerror", "custom error");
          }
        },
        batch: true,
        pageSize: 20,
        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 } }
            }
          }
        }
      });

      dataSource.read().then(function(){
        var productOne = dataSource.at(1),
            productTwo = dataSource.at(2);
        productOne.set("UnitPrice",42);
        productTwo.set("UnitPrice",42);
        dataSource.sync();
      });

  </script>
In this article
Not finding the help you need?