[Expand]General Information
[Collapse]WinForms Controls
  .NET Core Support
 [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]Get Started With Data Grid and Views
     [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]Filter and Search
       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
   [Expand]Data Binding
    Unbound Columns
   [Expand]Data Editing and Validation
   [Expand]Filter and Search
   [Expand]Focus and Selection Handling
    Format Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
    Split Presentation
    Row Preview Sections
   [Expand]Batch Modifications
    Hit Information
    Popup Menus
   [Expand]Save and Restore Layout
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Property Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gantt Control
  [Expand]Chart Control
  [Expand]Map Control
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Sunburst 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]Office File API
[Expand]Report and Dashboard Server
[Expand]eXpressApp Framework
[Expand]eXpress Persistent Objects
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation
View this topic on docs.devexpress.com (Learn more)

Tutorial: Group Summaries

This walkthrough is a transcript of the Group Summaries video available on the DevExpress YouTube Channel.

In this tutorial, you will learn how to create and customize summaries to be displayed in group rows and group footers. You will also see the built-in context menus and dialogs that allow end-users to add, remove or customize group summaries. Finally, you'll learn how to add group summaries in code.

Expanded Starting Point

Start with an application that has a GridControl with data already grouped.

Expanded Creating Group Summaries within Group Rows

To create a group summary that calculates the number of records in each group, invoke the Grid Designer and switch to the Group Summary Items Page and add a new item to the list. By default, the values will be displayed in group rows. Keep it that way for this summary. Set the GridSummaryItem.SummaryType property to SummaryItemType.Count. As the Count function simply calculates the number of records in each group, you can leave the GridSummaryItem.FieldName property empty. Use default text formatting for this summary.

Run the application. Group rows display the number of records within corresponding groups.

Expanded Creating Group Summaries within Group Footers

Return to design time. Go to the Group Summary Items designer page and add a new item. This summary item will calculate the maximum values in the Unit Price column and will be displayed in group footers under the same column. So, set both the GridSummaryItem.FieldName and GridGroupSummaryItem.ShowInGroupColumnFooter properties to UnitPrice. Then, set the GridSummaryItem.SummaryType property to SummaryItemType.Max. Finally, customize the display format of the summary value by setting the GridSummaryItem.DisplayFormat property.

Run the application. Expand the top group row to see its group footer with the newly created summary item in it.

Expanded Using Group Summary Context Menus

If group footers are visible, end-users can change existing group summaries or create new ones using built-in context menus. Right-click the summary item and change the type to Minimum.

The summary value is immediately updated. Now right-click a group footer cell under the Count column and choose Max thus adding a new summary item.

To hide an existing group summary, right-click it and select None.

Expanded Customizing Group Summaries

Using the Property grid, set the GridSummaryItem.SummaryType property back to SummaryItemType.Max and customize the summary's display format.

If you change the GridSummaryItem.FieldName property to OrderSum you'll get a summary value calculated against values in the OrderSum field.

You can also move the summary to another column's footer or to group rows using the GridGroupSummaryItem.ShowInGroupColumnFooter property.

Expanded Group Footer Visibility

If there are no group summaries to be displayed within group footers, footers disappear automatically.

Return to design-time. Select the grid View, expand its GridView.OptionsView property and set the GridOptionsView.GroupFooterShowMode to GroupFooterShowMode.VisibleAlways.

Run the application again. Now group footers are displayed for each group regardless of whether there are summary items to be displayed or whether the group row is expanded or collapsed.

Expanded Enabling and Using the Group Summary Editor

You can also enable the built-in UI so that end-users can create group summaries to be displayed in group rows. Expand the View's GridView.OptionsMenu property and enable the GridOptionsMenu.ShowGroupSummaryEditorItem option.

Run the application and right-click the grouping column header. Select Group Summary Editor... to invoke the summary editor dialog.

Locate the Order Sum column in the list of available columns, select the Average check box and click OK. Now, group rows display an additional summary with average values calculated against the Order Sum column.

Expanded Creating Group Summaries in Code

Finally, create a new group summary in code. Write a button's Click event handler, which creates a new GridGroupSummaryItem object, specifies its required properties and adds it to the View's GridView.GroupSummary collection.

Run the application and click the button. A new group footer summary appears under the Order Sum column.

Expanded See Also

Is this topic helpful?​​​​​​​