Is there a way to change the sort on GroupBy rows? or once you have GroupBy rows change their sorting?
thanks
-Ken
I'm not sure I am following you. If you click on a column header other than the one being grouped, then there's no reason for the GroupBySortComparer to be called. The GroupBySortComparer property is on the column. So it only applies to that column and it only applies when that column is grouped.
I can't see any reason why AfterSortChange would not fire, thoug, That doesn't make any sense.
bmm727 said:it seems that once I set the Comparer, I can't set it to a difference instance of IComparer btw
I don't understand what you mean by this. Why can't you set it to whatever you want?
Sorry I should have dug deeper on my own ... I think this may be related: http://news.infragistics.com/forums/p/9904/38767.aspx#38767
Does the GroupByComparer only get called when the Groups themselves get re-calculated? I've tried doing something like this:
void _grid_BeforeSortChange( object sender, BeforeSortChangeEventArgs e ) { /* update the GroupBySortComparer object here **/
e.SortedColumns.RefreshSort( true ); }
which sees to produce better results. The AfterSortChange event fires and the Comparer gets called (it seems that once I set the Comparer, I can't set it to a difference instance of IComparer btw) but the GroupByRows themselves do not change position. Do I need to sort the underlying data rows as well?
OK, so I've done that and its working in a sense. The problem I'm facing now is that when the user clicks on a column other than the group-by col. - I get the BeforeSortChanged event but no AfterChangedEvent. Also, the Comparer is never called. I'm not cancelling the event (right now the BeforeSortChanged event does nothing at all) so I would expect the AfterSortChanged event to fire - are there other conditions where the AfterSortChanged event will *NOT* be called?
Since the Comparer never gets called (and I have to think its related to the fact that the AfterSortChanged event is also not firing) - I can't adjust the sorting based upon the user intention yet.
Yes. What you can do is apply a GroupBySortComparer to the Product Type column. You need to create a class that implements IComparer and implements the Compare method. This method will pass you two UltraGridGroupByRows. You can examine each row and get the summary values from using groupByRow.Rows.SummaryValues and determine the correct compare value you want.
Hi Mike,
Is there anyway to change this behavior? e.g. - once I group the data in the grid, I want to be able to sort the groups themselves based upon a column that is DIFFERENT from the group-by col. For example, let's say I have columns "Price" and "Product Type" and the grid data is grouped on "Product Type" - I want to be able to sort the GroupByRows based upon the sum value of the Price in that GroupByRow.
For example, the data below:
| Price | Product Type | | 2 | Car | | 3 | Car | | 2 | Car | | 4 | Truck | | 1 | Truck |
Would have 2 summary rows: | Price | Product Type | | 7 | Car | | 5 | Truck |
and would be grouped on ProductType. I want to be able to sort by the Price of the GroupByRow (and ideally *within* the Group, by the specific items) NOT by the individual rows.
Is this possible? The solution I've done in the past was to copy the sort-by col into a separate hidden column and then include that column as one of the group-by columns.