push

Appends the given items to the array and returns the new length of the array. An equivalent of Array.prototype.push. The new items are wrapped as an ObservableObject if they are complex objects.

The push method raises the change event. The action field of the event argument is set to "add". The items field of the event argument is the array that contains the appended items.

Returns

Number—The new length of the array.

Parameters

item1, ..., itemN

The item or items that will be appended to the array.

Example - append an item to an ObservableArray

<script>
var array = new kendo.data.ObservableArray([{ name: "John Doe" }]);
var length = array.push({ name: "Jane Doe" });
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(length); // outputs "2"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(array[1] instanceof kendo.data.ObservableObject); // outputs "true"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(array[1].get("name")); // outputs "Jane Doe"
</script>

Example - append more than one item to an ObservableArray

<script>
var array = new kendo.data.ObservableArray([ 1 ]);
var length = array.push(2, 3);
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(length); // outputs "3"
/* The result can be observed in the DevTools(F12) console of the browser. */
console.log(array[1]); // outputs "2"
</script>
In this article