insert

Inserts a data item in the data source at the specified index.

Parameters

index Number

The zero-based index at which the data item will be inserted.

model Object|kendo.data.ObservableObject|kendo.data.Model

Either a kendo.data.Model instance or a JavaScript object containing the field values.

Returns

kendo.data.Model—The data item which is inserted.

Example - insert a data item

<script>
var dataSource = new kendo.data.DataSource({
  data: [
    { id: 1, name: "Jane Doe" }
  ],
  schema: {
    model: { id: "id" }
  }
});
dataSource.fetch(function() {
  var dataItem = dataSource.insert(0, { name: "John Doe" });
  var index = dataSource.indexOf(dataItem);
/* The result can be observed in the DevTools(F12) console of the browser. */
  console.log(index); // displays "0"
});
</script>
In this article