I'm creating a xamDataGrid that groups by a name column. This works perfectly, but the sort order on the group headers seems to be alphabetical and applying a sort order by the date column only sorts the rows within the groups, it doesn't re-order the group headers themselves into date order.
Is there any way to do this or am I heading down a dead-end?
Yes this is possible using GroupByComparer for particular field. For more details check out the attached sample application showing two ways how this could be implemented.
I hope this helps
-Vlad
On a sub note to ordering by GroupBy fields, is it possible to order the groups according to how many items each contains? So if I have a list of items, with owners, if I group by owner, can I then apply a sort so that the owner with the most items comes top of the list etc...
Thanks for the reply. It's working fine, I'm sharing the same ListCollectionView data source between a xamdatagrid and a listview. I have radio button that switches between the two "views". The xamdatagrid doesn't display as grouped when using the groupdescription of a listcollectionview is added, and that made my sorts look wonky, since it was really grouped first then sorted. I wrote code that adds or remove the groupdescriptions on the ListCollectionView depending if the xamdatagrid or listview is in focus. That solution works good for me. The info you gave could come in handy in the future. Thanks again.
@rp8049: I am sorry, I did not quite understood what you are trying to achieve. Can you please provide more information (screenshot,sample,steps to reproduce) about this problem.
@JoeGershgorin:
Have you tried the direction property of the SortDescription.
If the user is grouping, you can use the Grouping event:
void xamDataGrid1_Grouping(object sender, Infragistics.Windows.DataPresenter.Events.GroupingEventArgs e)
{
e.Groups[0].Direction = System.ComponentModel.ListSortDirection.Descending;
}
If the XamDataGrid is loaded as grouped, you should set this in the FieldLayout sorted fields collection.
Regards,
Alex.
I'm also interested in this. In my case I have a date field i would like grouped and sorted descending instead of ascending.