Is there a way to change the sort on GroupBy rows? or once you have GroupBy rows change their sorting?
thanks
-Ken
Hi Ken,
Ken Villines said:I am working with that event handler because it gives me direct access to a groupby row.
Why? You don't need a GroupByRow. The sorting is controlled on the column, not the GroupByRow. You are not even using the GroupByRow except to get the column. What you really need here is to look at the event args of the BeforeSortChange and examine the sorted columns. The GroupByRow has nothing to do with it.
Ken Villines said:An UltraGrid has a designtime property for regular row columns called SortIndicator. The programmer sets it in the designer and they are done. No need to deal with adding code to event handlers to change the sorting.The same can happen for Groupby rows.
I don't understand what you mean here. The sorting of GroupByRows and regular rows are both handled exactly the same way - by the SortIndicator on the column header.
Ken Villines said:If the user was given a new ultragrid property "GroupByRowSortIndicator" in the designer, then the UltraGrid could evaluate that whenever a Grouping occurs and set the sort to what the programmer wants. The default would be Ascending like it is now. Why is this hard to understand? You guys would be handling the logic in your base code instead of making third party programmers write event code to set sorting. The result is saving cycles for your users.
It sounds like what you want is a default sort order so that the first time you click on a column header or group on that column that it sorts in descending instead of ascending order. That makes sense and is certainly doable. But once again, it has nothing to do with GroupByRows, since they are no different than regular rows in this regard.
I am working with that event handler because it gives me direct access to a groupby row. I knew that I was setting the Sort each time a GroupBy row was initialized but I didn't think it was hurting anything. How are you proposing to use the BeforeSortChange? Like this?
void AssignmentHistoryGrid_BeforeSortChange(object sender, BeforeSortChangeEventArgs e) { UltraGridGroupByRow aGroupByRow = this.Rows[0] as UltraGridGroupByRow; if(aGroupByRow != null) aGroupByRow.Column.SortIndicator = SortIndicator.Descending; }
Even doing the above, means the programmer has to deal with an event handler to change the sort for group by rows. I am saying to add an Ultragrid property that gets evaluated on the base grid before the sorting happens.
An UltraGrid has a designtime property for regular row columns called SortIndicator. The programmer sets it in the designer and they are done. No need to deal with adding code to event handlers to change the sorting.The same can happen for Groupby rows.
If the user was given a new ultragrid property "GroupByRowSortIndicator" in the designer, then the UltraGrid could evaluate that whenever a Grouping occurs and set the sort to what the programmer wants. The default would be Ascending like it is now. Why is this hard to understand? You guys would be handling the logic in your base code instead of making third party programmers write event code to set sorting. The result is saving cycles for your users.
My 2cents
Hi,
I'm stil not sure I see your point here. In fact, I'm not really clear on what you are doing. Setting the SortIndicator inside the InitializeGroupByRow event doesn't seem like a good place to do this. You will basically be settings and re-setting this property on the same column object over and over for every GroupByRow. This is redundant and very inefficient.
Maybe I'm just not clear on what you are trying to accomplish here. But it sounds like maybe you just want to make the GroupByRow sort descending by default instead of asecending when the user groups by a column. If that's the case, then a better event to use would be the BeforeSortChange event.
True, I see your point....My point is that instead of having to do this work in an event handler. We should have a property that can be set on the UltraGrid (ie GroupByRowSortIndicator) so the Base.OnInitializeGroupByRow() can do the work for the programmer. Instead of having to know that the code below has to happen....I haven't seen the below solution anywhere in the forums. My proposed new property would also be available at design time. The below is not.
void HistoryGrid_InitializeGroupByRow(object sender, InitializeGroupByRowEventArgs e) { e.Row.Column.SortIndicator = SortIndicator.Descending; e.Row.RefreshSortPosition(); }
If you want to submit a feature request to Infragistics, you can do it here: Submit a feature request to Infragistics
But the sorting of the GroupByRows is determined by the sorting of the grouped column as you have obviously discovered. Why would you need an additional property for this when there is already a property to do it? That would be redundant.