Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Collapse]Data Grid
   [Collapse]Getting Started
    [Collapse]Walkthroughs
     [Expand]Appearance and Conditional Formatting
     [Expand]Data Editing
     [Expand]Hit Information
     [Expand]Data Binding and Working with Columns
     [Expand]Grid View - Columns, Rows and Cells
     [Expand]Banded Views
     [Expand]WinExplorer View
     [Expand]Tile View
     [Expand]Grouping
     [Expand]Filter and Search
     [Expand]Sorting
     [Collapse]Summaries
       Tutorial: Custom Summary Functions
       Tutorial: Format Summary Text
       Tutorial: Group Summaries
       Tutorial: Obtain Summary Values
       Tutorial: Sort Group Rows by Summary Values
       Tutorial: Total Summaries
     [Expand]Split Presentation
     [Expand]Row Preview Sections
     Data Grid and Views
   [Expand]Data Binding
   [Expand]Views
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Sorting
   [Expand]Filter and Search
   [Expand]Summaries
   [Expand]Focus and Selection Handling
    Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
    Scrolling
   [Expand]Batch Modifications
   [Expand]Hit Information
    Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Tutorial: Sort Group Rows by Summary Values

This walkthrough is a transcript of the Sort Group Rows by Summary Values video available on the DevExpress YouTube Channel.

The tutorial first shows the grid's built-in UI allowing you to sort group rows by summary values. You will then see how to disable this UI if needed, and how you can sort group rows in code.

Expanded Starting Point

Start with a GridControl already grouped against the Category column.

By default, group rows are automatically sorted in alphabetical order where the "Beverages" group row is followed by "Condiments", then by "Confections" and so on.

Expanded Adding a Group Summary

In the form Load event handler, create a group summary that calculates the maximum value in the OrderSum column. The summary values will be displayed in group rows.

Run the application. Group rows display the maximum values of the OrderSum column within each group.

Expanded End-User Capabilities

Right-click the Category column header, select the Sort by Summary item, and then Sort Ascending.

As a result, group rows are now sorted in ascending order based on summary values. A special glyph displayed within the grouping column indicates the current sort order.

In the same manner, you can reverse the sort order. To remove group row sorting, right-click the Category column header and select Clear Summary Sorting.

Expanded Restricting End-User Capabilities

Select the grid View, expand its GridView.OptionsMenu property and disable the GridOptionsMenu.ShowGroupSortSummaryItems option.

Run the application and right-click the Category column's header. The context menu that appears now as a result doesn't contain the Sort by Summary item.

Expanded Sorting by Summary Values in Code

Close the application again and return to the form Load event handler. Obtain the first grouping column from the View's ColumnView.SortInfo collection. To sort group rows in code, create a new GroupSummarySortInfo object. Use the summary item, target column and required sort order as parameters. Finally, clear the GridView.GroupSummarySortInfo collection and add the created object to it using the GroupSummarySortInfoCollection.ClearAndAddRange method.

Run the application to see the result. Group rows will now be sorted by summary values in ascending order.

Expanded See Also

How would you rate this topic?​​​​​​​