Hello,
I have created a group during design time that will group on the column "Error". Error has two values, true and false. When the grid is initially loaded, the rows all have "Error" set to false, so they all fall under the same GroupByRow.
At some later point, a particular row's "Error" cell will have its value updated in the InitializeRow event. After that, I am expecting the updated row to appear in under a different GroupByRow, but that is not happening. All the rows stay under the initial GroupByRow no matter how their "Error" value changes.
I have tried calling Row.Refresh() using the various parameters, and I have tried Row.Update(), and even Grid.Invalidate(), but nothing is working.
Does anyone know how to trigger a refresh and cause the GroupByRows to re-evaluate?
Try calling UltraGrid.Rows.Refresh()
The grid doesn't automatically update the sort or group positon of rows when the cell value changes, becasue this might cause odd behavior for users. For example, when a user changes the value in a cell and clicks away from that cell, the row would move and the grid would scroll and the spot they clicked might not be within the same row any more.
So it's left to you, the developer to decide when to refresh.
In this case, when you set the value on the cell, you can call the RefreshSortPosition method on the row. If you want to refresh the sorting (and grouping) of the whole band, you can use the band.SortedColumns.RefreshSort() method.
The RefreshSort method on the SortedColumns collection causes the entire grid to be re-sorted and re-grouped, so in that case, all of the rows GroupByRows will be collapsed, because the existing rows are destroyed and new GroupByRows are created. There is no way around that.
Using RefreshSortPosition will not have that problem, since it just moves a single existing row.
Mike Saltzman said: In this case, when you set the value on the cell, you can call the RefreshSortPosition method on the row. If you want to refresh the sorting (and grouping) of the whole band, you can use the band.SortedColumns.RefreshSort() method.
My colleague is working on an issue where would like the modified records to correct sort into the appropriate group. He found that by using the above methods to cause resort caused all groups to collapse. Is that a known side-effect? Is there any way to keep the grouping states intact?
In our app there are multiple grids and user may have expanded the groups specifically a certain way. To have such expansions of the various group undone by ths collapsing behavior is very user-unfriendly. So, we would like to find a way to retain the expansion while making the modified record resort/reposition correctly .
Thoughts, ideas?
Thank you very much! It works perfectly.