Add Multiple Items Such as an Array to Existing Kendo UI DataSource

datajs, kendo-ui

Solution

Lets say that you have the new data in an array called `newData`. You can use:

var newData = [
    { ... },
    { ... },
    { ... }
];

$.merge(newData, datasource._pristine);
datasource.data(newData);

Problem

I've been working on this for a few hours and cannot manage to find a way to get it to work properly. I'm looking for the proper way to add the contents of an array to an existing Kendo UI DataSource. Basically I have 4 SharePoint lists and I am fetching data using DataJS from each list. I want to then display the items in a Kendo GridView but I don't want to add the items using a `for` statement and the `add()` method. I have tried using the `add()` method on the array directly but all this does is add the array as an object itself to the DataSource and, of course, that is not the intended behavior. I also attempted using `dataSource.data.concat()` but received the error: Object doesn't support property or method 'concat'

Original source