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,
Please let me know if you have any questions.
Thank you for the update.
There is a possible way to do so. We may keep the transactions of the grid before we save and re-bind to the updated datasource. using allTransactions method. And we may re-apply the updates after rebind.
For more information on allTransactions method, please refer to the following documentation:
http://help.infragistics.com/jQuery/2012.2/ui.iggrid
If you have any questions, please let me know as well.
Looking forward to hearing from you.
Follow-on question for our second issue:
If the grid is already populated with data and transactions have occurred, we can't just replace the datasource since it will lose the user's changes. I suspect that we can save the transactions and then reapply them, but then we won't have transactions for the newly added records. Do you have a recommendation for this issue?
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.
Hello Karl Costenbader,
Please let me know how this works out.