Log In
[Expand]General Information
[Collapse]WinForms Controls
 [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
   [Expand]Getting Started
   [Expand]Binding to Data
   [Expand]Grid View
   [Expand]View Technology
     Summaries Overview
     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
     Total Summary
     Group Summary
     Custom Aggregate Functions
     Format Summary Values
     Obtain Summary Values
     Sorting Group Rows by Summary Values
     Controlling Visibility of Group Summaries for Individual Group Rows
   [Expand]Data Editing
   [Expand]Filtering and Locating Rows
   [Expand]Focus and Selection Handling
   [Expand]Processing Rows
   [Expand]Formatting Cell Values
   [Expand]Master-Detail Relationships
   [Expand]Asynchronous Image Load
   [Expand]Export and Printing
   [Expand]Appearance and Conditional Formatting
   [Expand]Batch Modifications
   [Expand]Hit Information
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [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]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Report Server
[Expand]eXpressApp Framework
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Group Summary

This topic provides information about group summaries. Basic summary information is presented in the Summaries Overview topic.

Expanded Online Video

Learn how to create and customize summaries to be displayed in group rows and group footers, how to use the built-in context menus and dialogs that allow end-users to manage group summaries and how to add group summaries in code.

Expanded Create Group Summary

Group summaries can be accessed by using the GridView.GroupSummary collection. It represents a GridGroupSummaryItemCollection class object and stores GridGroupSummaryItem objects.

You can add summary items to the collection both at design time and using code. To set up group summaries at design time, perform the following steps.

  1. Invoke the Group Summary Items Page of the Grid Designer.

  2. Add summary items by clicking the button and customize them.

    A single item is presented by a GridGroupSummaryItem class object, which is a GridSummaryItem class descendant. It provides the following main properties.

    - GridSummaryItem.SummaryType - Specifies the type of summary to calculate against groups.

    - GridSummaryItem.FieldName - Specifies the field against which the summary must be calculated.

    - GridGroupSummaryItem.ShowInGroupColumnFooter - Specifies where to display group summary values - in group rows or in a specific column's footer.

    - GridSummaryItem.DisplayFormat - Allows you to customize the display format of group summary values.

    The GridSummaryItem.DisplayFormat property is utilized for demonstration purposes here. To learn more about summary value formats, see Format Summary Values.

  3. Run the application. The group summaries will be displayed within group rows.

Expanded Group Summary Position

Group summaries can be displayed in two places.

The GridGroupSummaryItem.ShowInGroupColumnFooter property value determines where group summaries are to be displayed. If this property is set to null, the summary values are displayed within group rows, as in the image above. To display group summary values in group footers under a specific column, assign this column to the GridGroupSummaryItem.ShowInGroupColumnFooter property.

Note that the visibility of group footers is specified by the GridOptionsView.GroupFooterShowMode property. If the property value is set to Hidden, the group footers are not accessible to end-users.

The GridOptionsBehavior.AlignGroupSummaryInGroupRow option allows you to forcibly display group footer summaries in group rows under corresponding column headers and to hide group footers.

Expanded Group Summary Context Menus

If a Group Footer is visible, an end-user can change the existing group summaries or create new ones. To do this, an end-user needs to right-click a group footer cell under a specific column. The footer context menu will appear. That will allow the summary type to be changed, or a new summary to be created for the clicked column.

By default, group footers are visible only if group summaries exist. However, you can make group footers always available and thus make group footer context menus always available by setting the GridOptionsView.GroupFooterShowMode property to VisibleAlways.

To allow an end-user to define group summaries at runtime, set the GridOptionsMenu.ShowGroupSummaryEditorItem option. This option enables the Group Summary Editor menu command in the Column Header Context Menu for grouping columns. Selecting this option opens the Group Summary Editor.

To learn how to customize context menus, see the Implementing Custom Behavior for Popup Menus topic. When the GridSummaryItem.SummaryType property is set to Custom, the group footer context menu is not available.

Expanded Example

The following example shows how to create two group summary items. The first summary item will represent the number of records within groups, and will be displayed in group rows. The second item will calculate the sum of values against the UnitPrice field, and will be displayed under the Unit Price column within group footers. The result of the code execution is presented below:

Expanded See Also

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