GridColumnSummary.Type Property
Gets or sets the aggregate function type. This is a bindable property.
Namespace: DevExpress.Maui.DataGrid
Assembly: DevExpress.Maui.DataGrid.dll
NuGet Package: DevExpress.Maui.DataGrid
Declaration
public DataSummaryType Type { get; set; }
Property Value
Type | Description |
---|---|
DataSummaryType | The aggregate function type. |
Available values:
Name | Description |
---|---|
None | A summary is not calculated. |
Sum | The sum of values in a group of rows or an entire column. |
Min | The minimum value in a group of rows or an entire column. |
Max | The maximum value in a group of rows or an entire column. |
Count | The number of records in a group or an entire column. |
Average | The average value of a group of rows or an entire column. |
Custom | Specifies whether data summaries should be calculated according to a custom rule specified in the DataGridView.CustomSummary event handler. |
Remarks
Use the Type
property to specify the aggregate function that should be used to calculate the summary value. There are five predefined aggregate functions for grid data summaries: Sum, Min, Max, Average and Count.
To implement and apply a custom aggregate function, set the Type
property to Custom and handle the DataGridView.CustomSummary event.
Example
The following example uses predefined aggregate functions (Max and Sum) and a custom rule to calculate group and total summaries for a grid that displays orders grouped by dates.
Set up the following summaries:
- A group summary to display the maximum Total value for each group of orders.
- A total summary to calculate the sum of values in the Total column.
- A custom total summary to count the number of orders with the false value in the Shipped column.
<dxg:DataGridView x:Name="grid" ItemsSource="{Binding Orders}"
CustomSummary="grid_CalculateCustomSummary">
<!-- ... -->
<dxg:DataGridView.GroupSummaries>
<dxg:GridColumnSummary FieldName="Total" Type="Max"/>
</dxg:DataGridView.GroupSummaries>
<dxg:DataGridView.TotalSummaries>
<dxg:GridColumnSummary FieldName="Total" Type="Sum"
DisplayFormat="Total: {0:C0}"/>
<dxg:GridColumnSummary FieldName="Shipped" Type="Custom"
DisplayFormat="Not Shipped: {0}"/>
</dxg:DataGridView.TotalSummaries>
</dxg:DataGridView>
int count;
// ...
private void grid_CustomSummary(object sender, DevExpress.Maui.DataGrid.CustomSummaryEventArgs e) {
if (e.FieldName.ToString() == "Shipped")
if (e.IsTotalSummary) {
if (e.SummaryProcess == DevExpress.Maui.Core.DataSummaryProcess.Start) {
count = 0;
}
if (e.SummaryProcess == DevExpress.Maui.Core.DataSummaryProcess.Calculate) {
if (!(bool)e.Value)
count++;
e.TotalValue = count;
}
}
}