Edit this page

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 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>
Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy