wpf-devexpress-dot-xpf-dot-grid-dot-summaryitembase-54883e5c.md
Gets or sets the aggregate function type. This is a dependency property.
Namespace : DevExpress.Xpf.Grid
Assembly : DevExpress.Xpf.Grid.v25.2.Core.dll
NuGet Package : DevExpress.Wpf.Grid.Core
public SummaryItemType SummaryType { get; set; }
Public Property SummaryType As SummaryItemType
| Type | Description |
|---|---|
| SummaryItemType |
A SummaryItemType enumeration value that specifies the aggregate function type.
|
Available values:
| Name | Description |
|---|---|
| Sum |
The sum of all values in a column.
| | Min |
The minimum value in a column.
| | Max |
The maximum value in a column.
| | Count |
The record count.
| | Average |
The average value of a column.
| | Custom |
Specifies whether calculations should be performed manually using a specially designed event.
| | None |
Disables summary value calculation.
|
There are five predefined aggregate functions. These are: Sum , Min , Max , Average and Count. To implement your own aggregate function, set the SummaryType property to SummaryItemType.Custom, and handle the GridControl.CustomSummary event.
Average and Sum summaries are only calculated for columns that contain numerical data.
The following example demonstrates how to use custom summaries to count the total number of empty cells in the specified grid column:
View Example: How to Use Custom Summaries
<dxg:GridControl x:Name="grid"
CustomSummary="OnCustomSummary">
<dxg:GridControl.Columns>
<dxg:GridColumn FieldName="Text" GroupIndex="0" />
<dxg:GridColumn FieldName="Number" />
</dxg:GridControl.Columns>
<dxg:GridControl.View>
<dxg:TableView x:Name="view"
AutoWidth="True"
NavigationStyle="Cell"
TotalSummaryPosition="Bottom" />
</dxg:GridControl.View>
<dxg:GridControl.TotalSummary>
<dxg:GridSummaryItem DisplayFormat="Total empty cells count: {0}"
FieldName="Number"
SummaryType="Custom" />
</dxg:GridControl.TotalSummary>
<dxg:GridControl.GroupSummary>
<dxg:GridSummaryItem DisplayFormat="Group empty cells count: {0}"
FieldName="Number"
SummaryType="Custom" />
</dxg:GridControl.GroupSummary>
</dxg:GridControl>
void OnCustomSummary(object sender, CustomSummaryEventArgs e) {
if(((GridSummaryItem)e.Item).FieldName != "Number")
return;
if(e.SummaryProcess == CustomSummaryProcess.Start) {
e.TotalValue = 0;
}
if(e.SummaryProcess == CustomSummaryProcess.Calculate) {
if(IsEmptyCell(e.FieldValue))
e.TotalValue = (int)e.TotalValue + 1;
}
}
bool IsEmptyCell(object fieldValue) {
return !((int?)fieldValue).HasValue;
}
Private Sub OnCustomSummary(ByVal sender As Object, ByVal e As CustomSummaryEventArgs)
If Not Equals(CType(e.Item, GridSummaryItem).FieldName, "Number") Then Return
If e.SummaryProcess = CustomSummaryProcess.Start Then
e.TotalValue = 0
End If
If e.SummaryProcess = CustomSummaryProcess.Calculate Then
If IsEmptyCell(e.FieldValue) Then e.TotalValue = CInt(e.TotalValue) + 1
End If
End Sub
Private Function IsEmptyCell(ByVal fieldValue As Object) As Boolean
Return Not CType(fieldValue, Integer?).HasValue
End Function
The following code snippets (auto-collected from DevExpress Examples) contain references to the SummaryType property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
wpf-data-grid-process-frequent-data-updates/CS/ChunkAndOptSummariesExample/MainWindow.xaml#L18
<dxg:GridControl.TotalSummary>
<dxg:GridSummaryItem SummaryType="Count" FieldName="Name" DisplayFormat="Total count: {0:N0}"/>
</dxg:GridControl.TotalSummary>
how-to-bind-wpf-grid-to-data/CS/CodeBehind/EFCore/LocalData/MainWindow.xaml#L17
<dxg:GridControl.TotalSummary>
<dxg:GridSummaryItem SummaryType="Count" Alignment="Right" />
</dxg:GridControl.TotalSummary>
wpf-data-grid-implement-crud-operations/CS/CodeBehind/EFCore/LocalData/MainWindow.xaml#L38
<dxg:GridControl.TotalSummary>
<dxg:GridSummaryItem SummaryType="Count" Alignment="Right" />
</dxg:GridControl.TotalSummary>
wpf-data-grid-display-group-summaries/CS/DisplayGroupSummaries_CodeBehind/MainWindow.xaml#L19
<dxg:GridControl.GroupSummary>
<dxg:GridSummaryItem FieldName="Age" SummaryType="Min"/>
<dxg:GridSummaryItem FieldName="Age" SummaryType="Max"/>
wpf-data-grid-summarize-empty-cells/CS/CustomSummary_EmptyCells_CodeBehind/MainWindow.xaml#L24
FieldName="Number"
SummaryType="Custom" />
</dxg:GridControl.TotalSummary>
See Also