Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Expand]ASP.NET Controls and MVC Extensions
[Collapse]ASP.NET Bootstrap Controls
 [Expand]Getting Started
 [Collapse]Grid View
  [Expand]Binding to Data
  [Expand]Data Representation Basics
  [Collapse]Data Summaries
    Total Summary
    Group Summary
    Create Custom Summaries
  [Expand]Filtering
  [Expand]Grouping
   Sorting
  [Expand]Focus and Navigation
  [Expand]Data Editing
  [Expand]Master-Detail Relationship
   Export Overview
   Data-Toggle Attribute
 [Expand]Charts
 [Expand]Data Editors
 [Expand]Site Navigation and Layout
 [Expand]API Reference
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Create Custom Summaries

Total summaries and group summaries provide five predefined aggregate functions. These functions allow you to calculate the number of rows, the maximum and minimum values, the sum and the average value. If you need to calculate a summary value using an aggregate function not included in the predefined set, set the summary item's ASPxSummaryItemBase.SummaryType property to Custom and handle the Grid View control's ASPxGridBase.CustomSummaryCalculate event.

The ASPxGridBase.CustomSummaryCalculate event fires for each row involved in summary calculation. Take into account the difference between calculating the total and group summary values:

  • When calculating a total summary value, the event is raised for each data row in the grid.
  • When calculating a group summary value, the event fires for each data row within the currently processed group.

Additionally, the event is raised before and after processing rows, which can be used to perform any initialization and finalization.

Expanded Example

This example shows how to implement a custom summary calculation.

  1. Create a summary item within the ASPxGridView.TotalSummary collection, and customize its settings, as shown below:

  2. Handle the ASPxGridBase.CustomSummaryCalculate event to perform custom calculations in the code-behind. This example demonstrates how to calculate a summary only for selected rows.

    Note that in order to process selection changes on the server side, you can either set the ASPxGridBehaviorSettings.ProcessSelectionChangedOnServer property to true or handle the ASPxClientGridView.SelectionChanged client event, and call the ASPxClientGridView.PerformCallback client method.

The image below shows the result:

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