Hi
When I group by column the grid using "drag a column header here to group by that column" and I receive a new row (automatic),
the result is that I lose the groupby view and the Grid is shown as before I grouped by.
Is there any property which I can use to check if the grid is grouped by when I receive a new row?
Any idea how can I include the new row in the orderby grid view?
Thanks in advance
I don't understand your question. You are saying that when you group the grid, it ungroups? Why is it ungrouping? What do you mean by "receive a new row?"
Hi,
I understand josemon's question because I struggled with the same issue. What happens is the user groups by one column. Now the user expands a couple of the group by rows and decides she wants to to group by an additional column. The grid changes and the rows she already had expanded collapse. This is especially anoying when a relatively large amount of data is viewed. The same thing seems to happen when a row is added to the datasource.
I understand the way group by works, and I have come accross another thread where you explained how this might be prevented by using the BeforeSortChange and AfterSortChange events to manually keep track of the expanded rows(in BeforeSortChange) and restoring their expanded states(in AfterSortChange).
After a bit of trial and error I was able to implement the idea and it works well. A bit of psuedo code :
BeforeSortChange:
foreach grid row
{
if(row is GroupByRow and row is Expanded)
//Create a key for the row. UltraGridGroupByRow.Value works for me
rowKey = row.Value;
//Add\Update the row's expanded state to\in some sort of cache
cache.Add(rowKey, row.IsExpanded);
}
AfterSortChange :
if(row is GroupByRow)
//If we have this rowKey in our cache, change the row's expanded state
if(cache.Contains(rowKey)) row.Expanded = cache.GetValue(rowKey);