kendo ui - KendoUI Grid - Bulk import/setting of data very slow -


i ran problem importing data in bulk , setting values of existing rows taking long. usual symptoms browser hanging , "unresponsive script" alert.

here's code

function import() {     var datasource = $("#" + gridid).data("kendogrid").datasource;         var data = datasource.data;     var importeddata = null; // somewhere.....     for(var = 0; < data.length; i++) {         data[i].set("column-name-0", importeddata[i][0]);         data[i].set("column-name-1", importeddata[i][1]);     } } 

how fix slowness problem?

the "set" method mentioned above method of "observableobject", means each time set invoked, in turn triggers refresh of grid. imagine refreshing grid each cell modification in example above.

a solution not use set method set new values on model object directly , trigger grid refresh. see below.

function import() {     var grid = $("#" + gridid);     var datasource = grid.data("kendogrid").datasource;         var data = datasource.data;     var importeddata = null; // somewhere.....     for(var = 0; < data.length; i++) {         data[i]["column-name-0"] = importeddata[i][0]); // value should in correct datatype of column         data[i]["column-name-1"] = importeddata[i][1]);     }     grid.refresh(); } 

notice don't need play 'format' of column or 'template' of column, in case have been set. grid refresh automatically takes care of that.

however, make sure datatype of imported data matches datatype of column. if not, formatters have applied not work.

hope helps.


Comments

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -