I have a grid that is handling real-time data from the network and I allow the user to group and sum the data. Because the grid doesn't automatically recalculate the summary calculations i have to call RefreshSummaries on the RowsManagerBase class. But doing this doesn't work when grouping so I have to traverse all of the row managers by iterating the rows and grabbing the GroupByRows and calling their managers. This works but seems to use alot of CPU. I have a grid with about 1000 rows which the user groups into about 100 groups (100 rows per group). I have a timer and I am doing my RefreshSummaries every 2 seconds but it still uses enough CPU to where the grid lags significantly. Is there a better way to recalculate the summary information when using grouping?
Hi John,
The reason the XamGrid does not automatically refresh the summaries is for performance reasons. If the data was to be updated quite frequently, the data would need to be iterated and summaries recalculated. This is very expensive to do as you can see.
It sounds like your application is refreshing the summaries for every group all at once. A better approach might be to stagger the updates so that the application isn't hitting the cpu with a ton of work all at once. Spread out the updates over a longer period of time and you should see better performance. Maybe update two groups at a time and then wait a few milliseconds and then update the next two groups. To the user it will look like the summaries are updated almost instantly (users might still see some quickly changing numbers as the summaries are updated) but to the cpu there is more time to update summaries and still keep the UI responsive. The idea is to spread out the updates over the course of a few 100 milliseconds rather than doing it all at once.
I had already implemented the staggering as a workaround and it is OK. But i have found I can only really re-calculate the summaries for 1 group level (most times there are 3 levels) every 2 seconds. So each level ends up getting updated every 6 seconds. That is really not very often. With only 1000 rows and summing 1 column i would have expected to be able to do it much more often.