Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [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
   [Expand]Grouping
   [Expand]Sorting
   [Collapse]Summaries
     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]Hints
   [Expand]Popup Menus
   [Expand]Saving and Restoring Layouts
   [Expand]Visual Elements
   [Expand]Design-Time Features
   [Expand]Examples
   [Expand]End-User Capabilities
    Included Components
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Chart Control
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [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]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Tutorial: Total Summaries

This walkthrough is a transcript of the Total Summaries video available on the DevExpress YouTube Channel.

DevExpress GridControl allows you to display total values, such as the number of records, the maximum and minimum values in a column, and so on. In this tutorial, you will learn how end-users can add or remove totals using built-in footer menus, how to prevent them from customizing the totals you have specified, and how to pre-define the grid totals at design-time or in code.

Expanded Starting Point

Start with a GridControl displaying simple task data.

Expanded Displaying the View Footer

To enable total summary display and end-user interaction, you need to show the View Footer. To do this, expand the View's GridView.OptionsView property and turn on the GridOptionsView.ShowFooter option.

Expanded End-User Capabilities

Since the View's footer is now visible, end-users can add total summaries using footer context menus. Right-click the footer under the Unit Price column and select Count.

The footer cell now shows the total record count. In the Count column, show the sum of column values.

If you right-click an existing total summary cell, the Add New Summary menu item becomes available.

Use this item to create an additional summary that calculates the maximum value in the Unit Price column. You can also change a function used in a footer cell. Right-click the Count total summary and change the summary function to Min.

To hide a specific total value, right-click it and select None in the context menu. To hide all summaries under a specific column, use the Clear Summary Items option.

Expanded Restricting End-User Capabilities

If you don't want end-users to change predefined summaries, go to the Property grid displaying the View's settings, expand the GridView.OptionsMenu property and disable the GridOptionsMenu.EnableFooterMenu option. This disables the context menus and thus an end-user’s ability to manipulate summaries.

Expanded Creating Total Summaries at Design Time

The next step is to see how you can create total summaries at design time.

  • Creating a Single Summary

    Select the Unit Price column and expand its GridColumn.SummaryItem property. Leave the GridSummaryItem.FieldName property unchanged (its purpose will be discussed later). Set the GridSummaryItem.SummaryType property to SummaryItemType.Sum to specify the desired aggregate function. Finally, customize the summary value text formatting by setting the GridSummaryItem.DisplayFormat property.

    Run the application and note the specified summary value is displayed in the grid's footer.

    Then, use the GridSummaryItem.FieldName property that was left unchanged. Go to the Property grid displaying the Unit Price total summary settings and set the GridSummaryItem.FieldName property to the OrderSum field. You'll see that the summary value has changed as now, another field's values are used to calculate the total value.

  • Creating Multiple Summaries

    Return to design time and see how you can create multiple total summaries under a single column. Select the Order Sum column and click the ellipsis button next to the GridColumn.Summary property. This invokes a collection editor with one summary item already in the list, but having its summary type set to SummaryItemType.None. Change the type to SummaryItemType.Max to display the maximum value in the Order Sum column. The GridSummaryItem.DisplayFormat property is automatically changed. Add two new items by clicking the Add button. In the same manner, set their GridSummaryItem.SummaryType property to SummaryItemType.Min and SummaryItemType.Average, respectively. After that, click OK to save the changes and close the editor.

    Run the application again. The Order Sum column's footer displays three separate total values one under another.

Expanded Creating Total Summaries in Code

Finally, create total summaries in code. Write the Click event handler for the Create Summaries button. The handler creates two new GridColumnSummaryItem objects with the required summary types, field names and display formats. After that, it adds them to the GridColumn.Summary collection of the Count column.

Run the application and click the Create Summaries button. As a result, the Count column's footer displays the two specified totals.

Expanded See Also

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