I have a page where the user is able to select objects from Grid A to either 1) insert them into Grid B or 2) insert them into Grid C. One way to expedite use of the page is we want to allow users to have a button that does "Add all Visible in Grid A to Grid B". I have some javascript that does here
$("#addAllSelectedToGridB").click(function () { var gridA = $("#gridA").data("kendoGrid"); var gridB = $("#gridB").data("kendoGrid"); var gridBDatasource = gridB.dataSource; var alreadyInGridB = gridBDatasource.view(); var itemsToBeAdded = new Array(); gridA.select().each(function () { var dataItem = gridA.dataItem($(this)); var result = $.grep(alreadyInGridB, function (e) { return e.ID == dataItem.ID; }); if (result.length == 0) { itemsToBeAdded.push(dataItem); } }); for (i = 0; i < itemsToBeAdded.length; i++) { gridBDatasource.insert(itemsToBeAdded[i].toJSON()); }});This was working fine when we were displaying 25 items per page in Grid A. The customer has requested that we up that total to 300 and now an operation that took less than a second now takes 10-12 seconds.
I tried looking through the grid documentation but I couldn't find an alternative method for inserting items into a gird. I'm just curious if there is a method explicitly for adding a collection of items that may possibly be more efficient?
Thanks
