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

Controlling Visibility of Group Summaries for Individual Group Rows

By default, each group summary is calculated for each group row. This topic shows how to prevent specific group summaries from being calculated for individual group rows by handling the GridView.CustomSummaryExists event.

Consider the following GridControl that displays data grouped by the Country and City columns.

Suppose, you need to calculate two group summaries: 1) a sum against the Extended Price field, and 2) a count of records within groups. For the group rows that correspond to the Country group column, both of the two summaries need to be displayed, while group rows that correspond to the City group column should only display the count summary function, as demonstrated in the image below.

  1. Create group summaries.

    At design time, group summaries can be created using the Group Summary Items page of the Grid Control's Designer. Open this Designer page and create two group summaries with the + (Add) button.

    Initialize the group summaries as follows.

    Summary 1 (calculates the number or records within data groups):

    - SummaryType to Count;

    - Tag to 1 (a numeric value);

    Summary 2 (calculates a sum against the Extended Price field):

    - FieldName to "ExtendedPrice";

    - SummaryType to Sum;

    - Tag to 2 (a numeric value);

    - DisplayFormat to "Sum={0:c2}"

    Make note of the Tag properties being initialized for the summaries. This property will allow you to identify summaries when handling the GridView.CustomSummaryExists event.

    The following code shows how to create these group summaries at runtime.

    If you now run the application, the two summary functions will be calculated for each group row.

  2. Hide the Sum summary function for group rows that correspond to the City column.

    To hide certain group summaries, handle the GridView.CustomSummaryExists event. This event fires repeatedly for each group summary and for each group level before a summary calculation starts. To prevent a group summary from being calculated, set the Exists event parameter to false.

    Run the application to see the result.

Expanded See Also

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