Changes an ObservableArray, by adding new items while removing old items. Equivalent of Array.prototype.splice

Important: The splice method raises the change event once or twice depending on the change. The action field of the event argument is set to "add" (if items are added) or "remove (if items are removed). The items field of the event argument is the array that contains the appended items or removed items. In the above example the change event will be raised two times - first because "baseball" is removed and second because "tennis" and "hockey" are added.


Array containing the removed items. The result of the splice method is not an instance of ObvservableArray.


index Number

Index at which to start changing the array. If negative, will begin that many elements from the end.

howMany Number

An integer indicating the number of items to remove. If set to 0, no items are removed. In this case, you should specify at least one new item.

item1, ..., itemN (optional)

The items to add to the array. If you don't specify any items, splice simply removes items from the array.

Example - splice array items

var sports = new kendo.data.ObservableArray(["football", "basketball", "volleyball"]);
var removed = sports.splice(1, 1, "tennis", "hockey");
console.log(removed); // outputs ["basketball"]
console.log(sports); // outputs ["football", "tennis", "hockey", "volleyball"]
In this article
Not finding the help you need?