[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
   [Expand]Get Started With Data Grid and Views
   [Expand]Data Binding
    Unbound Columns
   [Expand]Data Editing and Validation
   [Expand]Filter and Search
     Working with Summaries in Code. Custom Summaries
   [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)

Working with Summaries in Code. Custom Summaries

Expanded Create Total Summaries

This example demonstrates how to add three total summaries with different types and aggregate functions.

Open the Manual total summary live demo and remove its code from the "ExampleCode" tab. Create three GridSummaryItem objects:

  • a summary item for displaying total record count - does not require setting the GridSummaryItem.FieldName property;
  • a summary item for calculating an average length - utilizes a custom {0:#.#} display format;
  • a summary item with a custom aggregate function.

For the third summary item, you need to provide a custom aggregate function that calculates the summary value. To do so, handle the GridView.CustomSummaryCalculate event. The code sample below determines if the processed order belongs to the current week, and if so, increments the summary.

Add all three summary items to the GridColumn.SummaryItem collections of required columns and explicitly show the View footer by enabling the GridOptionsView.ShowFooter setting.

Expanded Create Group Summaries

The code below creates three group summaries. You can test this sample in the Manual total summary demo.

  • a "Count" summary displayed in group rows;
  • an "Average" summary shown in group footer area;
  • a group footer summary with a custom aggregate function.

To add group summaries in code, you need to either manually create GridGroupSummaryItem objects and place them inside the GridView.GroupSummary collection, or call the collection's Add method with required parameters.

A summary with a custom aggregate function requires handling the GridView.CustomSummaryCalculate event to calculate a summary value.

Expanded Obtain Summary Values

Utilize the following API to retrieve summaries, their values and displayed text.

Common API


Gets the value of this summary item.


Applies the current display format rule expression to convert any value into a display text.

Total Summaries


Returns the text displayed by total summaries owned by this column. The return value is a single string that delimits values of separate summaries with the "\r\n" sequence (e.g., "Max: 1007.6400\r\n830 records").

Group Summaries


Takes a row handle and a column as parameters and returns a DictionaryEntry object that provides access to:

  • a summary item associated with these row and column - accessed through the DictionaryEntry.Key property;
  • a summary item's value - accessed through the DictionaryEntry.Value property.

The code sample below retrieves a group summary item text whenever the focused row changes.

GridView.GetGroupSummaryValue, GridView.GetGroupSummaryDisplayText

Return the value and the display text of the specific group summary item for a specific group.


Returns the hashtable that stores pairs of summary items (keys) and their values (values) for the given row handle. The hashtable contains entries for summary items displayed in both group footers and group rows.


Returns the text, displayed by group summary items in a group row.


Call this method to retrieve text, displayed by a specific summary item in a group footer.


The following code utilizes summary access API to perform the following customizations:

  • groups with more than three child items are highlighted with red;
  • display text of total summaries is changed without modifying these summaries' display formats.

Expanded Manually update summaries

Data Grid updates its summaries when a user focuses another row, or presses the "End Init" Data Navigator button. You can disable this automatic update for total summaries to improve the overall Grid performance on large data sources. To do that, disable the GridOptionsBehavior.AutoUpdateTotalSummary setting.

If you need to forcibly update summaries, call one of the following methods.

In the following example, the "Quantity" column has a total "Count" summary. The code updates this summary immediatelly after a user has changed a value of any cell that belongs to this column.

Expanded See Also

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