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?
I'm also interested in this. In my case I have a date field i would like grouped and sorted descending instead of ascending.
@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.
Hi,
I have groupings with the totals displaying in the group headers for all the numeric columns(ex col2, col3, col4) and group by is applied on col1 and colm5. If I sort by col2, I need the group by header to sort based on the totals for col2 on the group header. If i use custom GroupByComparer, it gives me GroupByRecord object for comparision, GroupByRecord object has just the description and not the cells by summary values(totals on the header) which I can use for sort comparision. How can I get the Totals on each of the group header from GroupByRecord.
Hello Jaffar,
You can use the following code, where “gbr” is the GroupByRecord:
int result; var summary = gbr.DescriptionWithSummaries.TrimStart(gbr.Description.ToCharArray()).Split(new char[]{' ',','}); for (int i = 0; i < summary.Length; i++) { if (summary[i] == "Count") { result = Int32.Parse(summary[i + 2]); } }
Hope this helps you.
Hi Stefan,
DescriptionWithSummaries has just the description(ex. "27,175.00 (1 item)") and not the totals, as i am setting teh GroupBySummaryDisplayMode to "SummaryCellsAlwaysBelowDescription" and not text . I tried iterating the child records but they too just have the descriptions.
Thnx
Jaffar
If you set the GroupBySummaryDisplayMode to SummaryCellsAlwaysBelowDescription yo ucan use the following code:
Dispatcher.BeginInvoke(new Action(() => { GroupByRecordPresenter gbrp = GroupByRecordPresenter.FromRecord(gbr) as GroupByRecordPresenter; GroupBySummariesPresenter gbsp = Utilities.GetDescendantFromType(gbrp, typeof(GroupBySummariesPresenter), true) as GroupBySummariesPresenter; int result = Int32.Parse(gbsp.SummaryResults.Where(t => t.DisplayText.Contains("Count")).FirstOrDefault().Value.ToString()); }), DispatcherPriority.Background, null);
A workaround will be to use different sortComparer for different columns, but If I know the columns being sorted it will be more generic.
Thanks Stefan, this works fine if I have 1 column with total ... but if I have 2 columns with total in the summary, is there a way to know which column is being sorted in the sortcomparer... I can get the individual total value of these columns from SummaryDefinition in the SummaryResults but dont know which column value to use for comparision as I dont have the current column on which sort is being applied.