pushUpdate
Updates the specified data items without marking them as "dirty". The data source will not sync data items appended via pushUpdate
. If the data items are not found (using schema.model.id
), they will be appended.
The difference between
pushUpdate
and updating items via their set method is that items updated via set are synced with the remote service.
Parameters
items Object|Array
The data item or data items to update.
Example - pushUpdate with a single item
<script>
var dataSource = new kendo.data.DataSource({
schema: {
model: {
id: "id"
}
},
data: [
{ id: 1, name: "John Doe" }
]
});
dataSource.read();
dataSource.pushUpdate({ id: 1, name: "Jane Doe" });
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.at(0).name); // displays "Jane Doe"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.at(0).dirty); // displays "false"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.hasChanges()); // displays "false"
</script>
Example - pushUpdate with multiple items
<script>
var dataSource = new kendo.data.DataSource({
schema: {
model: {
id: "id"
}
},
data: [
{ id: 1, name: "John Doe" },
{ id: 2, name: "Jane Doe" }
]
});
dataSource.read();
dataSource.pushUpdate([
{ id: 1, name: "John" },
{ id: 2, name: "Jane" }
]);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.at(0).name); // displays "John"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.at(0).dirty); // displays "false"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(dataSource.hasChanges()); // displays "false"
</script>