New to Kendo UI for jQueryStart a free 30-day trial

Splice

methods

Changes an ObservableArray by adding new items while removing old items. An equivalent of Array.prototype.splice.

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 previous example, the change event will be triggered two times—the first one, because baseball is removed and, the second one, because tennis and hockey are added.

Parameters:indexNumber

An index at which the changing of the array will start.

howManyNumber

An integer which indicates the number of the items for removal. If set to 0, no items will be removed. In this case, you have to specify at least one new item.

Returns:Array

—Contains the removed items. The result of the splice method is not an instance of ObvservableArray.

<script>
var sports = new kendo.data.ObservableArray(["football", "basketball", "volleyball"]);
var removed = sports.splice(1, 1, "tennis", "hockey");
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(removed); // outputs ["basketball"]
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(sports); // outputs ["football", "tennis", "hockey", "volleyball"]
</script>
Not finding the help you need?
Contact Support