We have numerous scenarios where we need to perform bulk updates of the grid in response to user requests.
These bulk updates fall into two general categories:
1) Setting specific properties in the data (usually bit flags)
2) Adding a number of rows to the grid (usually a large number)
For scenario 1, we have tried using setCellValue, but even updating 100 rows takes 15 seconds using code similar to the following:
var cGridRows = oGridJQ.igGrid("allRows"); var sRowId; $.each(cGridRows, function (wIndex, oGridRow) { if ((oGridRow.style.visibility == "hidden") || (oGridRow.style.display == "none")) { // Don't process hidden rows } else { sRowId = oGridRow.attributes("data-id").value; // If IsSelected is not the same as the requested value if (oGridJQ.igGrid("getCellValue", sRowId, "IsSelected") != fValue) { // Update the row with the requested value oGrid.Grid.igGridUpdating("setCellValue", sRowId, "IsSelected", fValue); } } });
Every time I break in javascript debugger while this is happening, it is in _renderData.
What we would like to do is update the data source directly, then refresh the grid.
I know how to update the data source directly, but that doesn't update the grid. And if I call bindData, it uses the original data, not the updated data since the direct datasource updates are not transacted (we use autoCommit).
Here is code similar to what we use for this second approach:
var cGridRows = oGridJQ.igGrid("allRows"); var oDataSource = oGridJQ..igGrid("option", "dataSource").data(); var oDataRow; var fAnyUpdated = false; $.each(cGridRows, function (wIndex, oGridRow) { if ((oGridRow.style.visibility == "hidden") || (oGridRow.style.display == "none")) { // Don't process hidden rows } else { oDataRow = oDataSource[wIndex]; // If IsSelected is not the same as the requested value if (oDataRow.IsSelected != fValue) { fAnyUpdated = true; // Update the row with the requested value oDataRow.IsSelected = fValue; } } }); if (fAnyUpdated) { oGridJQ.igGrid("dataBind"); }Performance is critical to our end users and they work with somewhat large datasets on a regular basis, (1000-3000 records).
We switched from UltraWebGrid to igGrid specifically due to performance issues, but now this issue is threatening to derail the entire project.
Can we please get some assistance with this?
Hello Karl Costenbader,
Thank you for contacting Infragistics!
For the second approach, you may set the datasource of the grid to the updated datasource, oDataSource as follows:
oGridJQ.igGrid('option','datasource',oDataSource);
If you have any questions, please let me know as well.
Thank you for the quick response! This worked like a charm!!!
The only change I made was to use dataSourceObject instead of directly accessing options.dataSource since that is what the documentation suggests, but looking at the code I don't see any difference between the two.
Please let me know how this works out.