sync
Fired after the data source saves data item changes. The data source saves the data item changes when the sync method is called.
The event handler function context (available via the this
keyword) will be set to the data source instance.
The
sync
event is fired after all remote requests finish.
Event Data
e.sender kendo.data.DataSource
The data source instance which fired the event.
Example - subscribe to the sync event during initialization
<script>
var dataSource = new kendo.data.DataSource({
batch: true,
transport: {
create: {
url: "https://demos.telerik.com/kendo-ui/service/products/create",
dataType: "jsonp" //"jsonp" is required for cross-domain requests; use "json" for same-domain requests
},
parameterMap: function(data) {
return { models: kendo.stringify(data.models) };
}
},
sync: function(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log("sync complete");
},
schema: {
model: { id: "ProductID" }
}
});
dataSource.add( { ProductName: "Ham" } );
dataSource.sync();
</script>
Example - subscribe to the sync event after initialization
<script>
function dataSource_sync(e) {
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log("sync complete");
}
var dataSource = new kendo.data.DataSource({
batch: true,
transport: {
create: {
url: "https://demos.telerik.com/kendo-ui/service/products/create",
dataType: "jsonp" //"jsonp" is required for cross-domain requests; use "json" for same-domain requests
},
parameterMap: function(data) {
return { models: kendo.stringify(data.models) };
}
},
schema: {
model: { id: "ProductID" }
}
});
dataSource.bind("sync", dataSource_sync);
dataSource.add( { ProductName: "Ham" } );
dataSource.sync();
</script>