We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Sort by Summary Column

Thread ID:

Created:

Updated:

Platform:

Replies:

43160 Apr 17,2006 03:32 PM UTC May 22,2007 01:14 AM UTC Windows Forms 2
loading
Tags: GridControl
Eric Robishaw
Asked On April 17, 2006 03:32 PM UTC

I''ve followed the example, SortBySUmmaryInCaption and it does not do what I need regarding sorting with summaries. If I add 3 summary columns (SUM, MIN, MAX), and then let the USER group by dragging a column to the group bar, I want the the user to be able to sort by those three columns (or any other columns), so that when collapsed, the sorting is in the Aggregates (SUM, MIN, mAX), but when expanded, it is sorted by the underlying values. I know that I can attach to the grid.TableDescriptor.GroupedColumns.Changed event, which returns the SortColumnDescriptor that is added / removed by the user... do I then have to track what columns have been sorted and reset my own sort handlers? FOR EXAMPLE: Run the SortBySUmmaryInCaption demo example, remove the ShipCountry from the group, and then group by EmployeeID by dragging to the group bar. Now, click the Freight column. Since the freight column contains a summary column with averages of freight, and while groups are collapsed, I would expect the groups to sort by Freight. When the user clicks Freight again, I would expect a reverse sort.

Administrator [Syncfusion]
Replied On April 18, 2006 02:13 PM UTC

Hi Robishaw, The sort order of the groups can be reversed by just calling sortColumnDescriptor.SetGroupSummarySortOrder(), passing the intent sort order. Below is a code snippet. Please try this in the SortBySUmmaryInCaption sample and let us know if you need any further assistance. this.gridGroupingControl1.TableControlQueryAllowSortColumn += new GridQueryAllowSortColumnEventHandler(gridGroupingControl1_TableControlQueryAllowSortColumn);//Add this event handler. ListSortDirection sortDir = ListSortDirection.Ascending; private void gridGroupingControl1_TableControlQueryAllowSortColumn(object sender, GridQueryAllowSortColumnEventArgs e) { foreach(Group g in this.gridGroupingControl1.Table.TopLevelGroup.Groups) { if(g.IsExpanded) return; } if(this.gridGroupingControl1.TableDescriptor.GroupedColumns.Count>0) { GridSummaryRowDescriptor summaryRow = this.gridGroupingControl1.TableDescriptor.SummaryRows["Caption"]; GridSummaryColumnDescriptor summary= summaryRow.SummaryColumns["FreightAverage"]; SortColumnDescriptor gsd = this.gridGroupingControl1.TableDescriptor.GroupedColumns[0]; if(sortDir == ListSortDirection.Ascending) { sortDir = ListSortDirection.Descending; gsd.SetGroupSummarySortOrder(summary.GetSummaryDescriptorName(), "Average",sortDir); } else { sortDir = ListSortDirection.Ascending; gsd.SetGroupSummarySortOrder(summary.GetSummaryDescriptorName(), "Average",sortDir); } } } Regards, Calvin.

Stuart Faircloth
Replied On May 22, 2007 01:14 AM UTC

Hi Calvin,

This solution appears to work if you just want to sort for 1 column. If you require sorting on multiple columns it will only sort on the last column selected.

Do you know how to solve my problem?

Thanks

Stuart

>Hi Robishaw,
>
>The sort order of the groups can be reversed by just calling sortColumnDescriptor.SetGroupSummarySortOrder(), passing the intent sort order. Below is a code snippet. Please try this in the SortBySUmmaryInCaption sample and let us know if you need any further assistance.
>
>this.gridGroupingControl1.TableControlQueryAllowSortColumn += new GridQueryAllowSortColumnEventHandler(gridGroupingControl1_TableControlQueryAllowSortColumn);//Add this event handler.
>
>
> ListSortDirection sortDir = ListSortDirection.Ascending;
> private void gridGroupingControl1_TableControlQueryAllowSortColumn(object sender, GridQueryAllowSortColumnEventArgs e)
> {
> foreach(Group g in this.gridGroupingControl1.Table.TopLevelGroup.Groups)
> {
> if(g.IsExpanded)
> return;
> }
> if(this.gridGroupingControl1.TableDescriptor.GroupedColumns.Count>0)
> {
> GridSummaryRowDescriptor summaryRow = this.gridGroupingControl1.TableDescriptor.SummaryRows["Caption"];
> GridSummaryColumnDescriptor summary= summaryRow.SummaryColumns["FreightAverage"];
> SortColumnDescriptor gsd = this.gridGroupingControl1.TableDescriptor.GroupedColumns[0];
> if(sortDir == ListSortDirection.Ascending)
> {
> sortDir = ListSortDirection.Descending;
> gsd.SetGroupSummarySortOrder(summary.GetSummaryDescriptorName(), "Average",sortDir);
> }
> else
> {
> sortDir = ListSortDirection.Ascending;
> gsd.SetGroupSummarySortOrder(summary.GetSummaryDescriptorName(), "Average",sortDir);
>
> }
>
> }
> }
>
>Regards,
>Calvin.

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;