Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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'

like image 660
Robert Kaucher Avatar asked Dec 11 '22 16:12

Robert Kaucher


1 Answers

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);
like image 104
OnaBai Avatar answered May 09 '23 18:05

OnaBai