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);
  console.log(index); // displays "0"
});
</script>
In this article
Not finding the help you need? Improve this article