Hi,
I have a grid that is updated in real time couple of times a second. As far as the user is concerned, it is a read-only data grid. The user does not edit any cells, just views the updates. The purpose of the grid is to display the latest items at the top. This involves in having one of the fields (a time stamp) sorted.
Without the sort, the grid performs perfectly fine. However, when the sort is applied, the grid suffers from considerable performance, to the point where it becomes almost unusable.
I'm aware that by design, the datagrid will *not* automatically maintain the sort when the datasource is updated. The way the sort is applied, is using a workaround (mentioned here in several places) of removing and applying the sorted fields as to always automatically maintain the sort on every update.
FieldSortDescriptionCollection sortedFields = _myDataGrid.DefaultFieldLayout.SortedFields;var sfd = sortedFields.Where(sortField => !sortField.IsGroupBy).ToList();foreach(var sf in sfd){ sortedFields.Remove(sf);}foreach(var sf in sfd){ sortedFields.Add(sf);}
...Alternatively I can do this, with equally poor performance results, but then sorting under grouping doesn't work:
_myDataGrid.Records.RefreshSort();
I'm not concerned with the workarounds for getting the sort to work under grouping, but just purely the performance of the infragistics sort. I've tried to even provide my own SortComparer in the field settings of the field I am sorting, and I still get the poor performance.
Is there any way I can maintain my sort in real-time without such a huge performance penalty?
Thanks Aldrick,
1. Will try.
2. Already doing that.
3. I tried providing my own SortComparer to that field property. Even if I don't do anything in my method (return 1) I still see a performance penalty. Not sure it's related to the sort function. In any case, sorting datetime should be nothing more comparing the number of ticks, which is trivial.
4. Not sure I understand.
Seems like a pretty big limitation of the grid if you can't sort and update at the same time in real-time.
Hi, rianvii
There are several things you could try:
1. Consider suspend the data update before sorting and resume it after.
2. Consider shorten the data update or merge several updates into one.
3. Consider sort the data source with your own logic instead of using the sort provided by XamDataGrid.
4. It is possible to remove the sort since you are only sort by time stamp? Consider a pattern of insert/remove against the data source?
Thanks
Aldrick