Skip to main content
A newer version of this page is available. .

Data Summaries

  • 3 minutes to read

Total Summary

A total summary is a value of an aggregate function calculated over all data rows displayed in the GridControl. Total summaries are displayed in the Summary Panel or Fixed Summary Panel. To show these panels, enable the DataControlBase.ShowTotalSummary and DataControlBase.ShowFixedTotalSummary options, respectively. Fixed Summaries are always visible onscreen, regardless of the corresponding column’s position and visibility.

WinUI Grid: Total Summary

Display Total Summaries

The GridControl stores its total summaries in the GridControl.TotalSummary collection.

To display a summary item in the Fixed Summary Panel, specify the GridTotalSummaryItem.Alignment property to align it to the Left or Right. If this property is set to Default, the GridControl displays a summary item in the Summary Panel.

<dxg:GridControl.TotalSummary>
    <dxg:GridTotalSummaryItem FieldName="UnitPrice" SummaryType="Max"/>
    <dxg:GridTotalSummaryItem FieldName="Quantity" SummaryType="Average"/>
    <dxg:GridTotalSummaryItem SummaryType="Count" Alignment="Left"/>
    <dxg:GridTotalSummaryItem FieldName="Quantity" SummaryType="Sum" Alignment="Right"/>
</dxg:GridControl.TotalSummary>

To create a total summary in code:

  1. Create a new instance of the GridTotalSummaryItem class.
  2. Specify its FieldName and SummaryType properties.
  3. Add the instance to the GridControl.TotalSummary collection.
  4. To display a summary item in the Fixed Summary Panel, specify the GridTotalSummaryItem.Alignment property to align it to the Left or Right.
using DevExpress.Data;
using DevExpress.WinUI.Grid;

// ...
grid.TotalSummary.Add(new GridTotalSummaryItem() { 
    SummaryType = SummaryItemType.Count, 
    Alignment = SummaryItemAlignment.Left 
});
grid.TotalSummary.Add(new GridTotalSummaryItem() { 
    SummaryType = SummaryItemType.Max, 
    FieldName = "UnitPrice", 
    DisplayFormat = "Max: {0:c2}" 
});
grid.TotalSummary.Add(new GridTotalSummaryItem() { 
    SummaryType = SummaryItemType.Sum, 
    FieldName = "Quantity" 
});

Obtain Summary Values

To obtain a total summary value, use the DataControlBase.GetTotalSummaryValue method.

Use the ColumnBase.TotalSummaries property to get a list of total summaries displayed in a column.

Use the DataControlBase.FixedSummariesLeft and DataControlBase.FixedSummariesRight properties to obtain total summaries aligned to the Left or to the Right, respectively.

Group Summary

A group summary is a value of the aggregate function calculated over all data rows within a group. The GridControl displays group summaries in group rows.

WinUI Grid: Group Summary

Refer to the following help topic for more information: Sort Group Rows by Summary Values.

Display Group Summaries

The GridControl stores its group summaries in the GridControl.GroupSummary collection.

<dxg:GridControl.GroupSummary>
    <dxg:GridGroupSummaryItem FieldName="UnitPrice" SummaryType="Max" DisplayFormat="Max Price: {0:c}"/>
</dxg:GridControl.GroupSummary>

To display group summaries in code, create a new instance of the GridGroupSummaryItem class, specify its properties, and add it to the GridControl.GroupSummary collection.

using DevExpress.Data;
using DevExpress.WinUI.Grid;

// ...
grid.GroupSummary.Add(new GridGroupSummaryItem() {
    FieldName = "UnitPrice",
    SummaryType = SummaryItemType.Max,
    DisplayFormat = "Max Price: {0:c}"
});

Align Group Summaries By Columns

To display group summaries under corresponding columns, set the GridControl.GroupSummaryDisplayMode to GroupSummaryDisplayMode.AlignByColumns.

WinUI Grid: Align Group Summary

See Also