New to Kendo UI for jQueryStart a free 30-day trial

Sync

methods

Saves any data item changes.

The sync method will request the remote service if:

  • The transport.create option is set and the data source contains new data items.
  • The transport.destroy option is set and data items have been removed from the data source.
  • The transport.update option is set and the data source contains updated data items.
Returns:Promise

—A promise that will be resolved when all sync requests have finished successfully, or rejected if any single request fails.

<script>
var dataSource = new kendo.data.DataSource({
  batch: true,
  transport: {
    read:  {
        url: "https://demos.telerik.com/service/v2/core/products",
        dataType: "json"
    },
    update: {
      url: "https://demos.telerik.com/service/v2/core/products/update",
      type: "POST",
      contentType: "application/json"
    },
    destroy: {
      url: "https://demos.telerik.com/service/v2/core/products/destroy",
      type: "POST",
      contentType: "application/json"
    }
  },
  schema: {
    model: { id: "ProductID" }
  }
});
dataSource.fetch(function() {
  var product = dataSource.at(0);
  product.set("UnitPrice", 20);
  var anotherProduct = dataSource.at(1);
  anotherProduct.set("UnitPrice", 20);
  var yetAnotherProduct = dataSource.at(2);
  dataSource.remove(yetAnotherProduct);
  dataSource.sync(); // makes a request to https://demos.telerik.com/service/v2/core/products/update" and https://demos.telerik.com/service/v2/core/products/destroy
});
</script>
Not finding the help you need?
Contact Support