Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Collapse]WPF Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Expand]MVVM Framework
 [Collapse]Controls and Libraries
  [Expand]Windows and Utility Controls
   Dialogs, Notifications and Panels
   Reporting
  [Collapse]Data Grid
   [Expand]Getting Started
   [Expand]Implementation Details
   [Expand]Views
   [Expand]Grid View Data Layout
   [Expand]Binding to Data
   [Expand]Master-Detail Data Representation
   [Expand]Data Editing and Validation
   [Expand]Grouping
   [Expand]Selection
   [Expand]Filtering and Searching
   [Expand]Sorting
   [Collapse]Data Summaries
     Data Summaries Overview
     Total Summary
     Group Summary
     Node Summary
     Custom Summary
     Runtime Summary Editor
   [Expand]Paging and Scrolling
   [Expand]Focus and Navigation
   [Expand]Conditional Formatting
   [Expand]Drag-and-Drop
   [Expand]Appearance Customization
   [Expand]MVVM Enhancements
   [Expand]Printing and Exporting
   [Expand]End-User Interaction
   [Expand]Miscellaneous
   [Expand]Performance Improvement
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]End-User Capabilities
   [Expand]Examples
  [Expand]Ribbon, Bars and Menu
  [Expand]Charts Suite
  [Expand]Pivot Grid
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Tree List
  [Expand]Gauge Controls
  [Expand]Map Control
  [Expand]Layout Management
  [Expand]Windows Modern UI
  [Expand]Printing-Exporting
  [Expand]Data Editors
  [Expand]Navigation Controls
  [Expand]Spell Checker
  [Expand]Property Grid
  [Expand]PDF Viewer
  [Expand]TreeMap Control
  [Expand]Diagram Control
  [Expand]Scheduler (legacy)
 [Expand]Scaffolding Wizard
 [Expand]Localization
  Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Office File API
[Expand]Reporting
[Expand]Report and Dashboard Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Custom Summary

Total summaries and group summaries provide five predefined aggregate functions. These functions allow you to calculate:

  • the number of data rows (Count)
  • the maximum and minimum values (MAX and MIN)
  • the sum and the average value (SUM and AVG).

If you want to calculate summaries using custom rules, handle the GridControl.CustomSummary event. This event enables you to implement custom aggregate functions or calculate summary values, using a custom algorithm. Custom summaries allow you to:

  • calculate summaries against records that meet specific criteria
  • involve multiple data fields in calculations
  • implement complex summary functions (e.g. the standard deviation of a population), etc.

Expanded General Information

To calculate a summary manually:

The GridControl.CustomSummary event fires for each data row involved in summary calculation. When calculating a total summary value, the event is raised for each data row (or card in a Card View). When calculating a group summary value, this event fires for each data row (card) within a group. To enable you to perform any initialization and finalization, the event is also raised before and after processing rows.

The summary calculation consists of the three stages:

  • Initialization

    The CustomSummary event is raised once and the CustomSummaryEventArgs.SummaryProcess property is set to CustomSummaryProcess.Start. At this stage you can initialize summary values (e.g. reset internal counters).

  • Calculation

    The CustomSummary event occurs multiple times, once for each data row in a View or group. The SummaryProcess property is set to CustomSummaryProcess.Calculate. At this stage you should accumulate summaries.

  • Finalization

    The CustomSummary event is raised once and the SummaryProcess property is set to CustomSummaryProcess.Finalize. At this point, calculate a final summary value and assign it to the event parameter's CustomSummaryEventArgs.TotalValue property.

To skip the Calculation stage and calculate a custom summary at the Initialization or Finalization stage, set the event parameter's CustomSummaryEventArgs.TotalValueReady property to true at the Initialization stage. This automatically skips the Calculation stage and the Finalization stage starts immediately.

Expanded Example

Show Me

A complete sample project is available in the DevExpress Code Examples database at http://www.devexpress.com/example=E948.

The following example demonstrates how to use custom summaries to count the total number of empty cells in the specified grid column.

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