Blazor DataGrid Example - Default Aggregation
Customer ID | Freight | Order Date | Ship Country |
|---|
| No records to display |
This sample demonstrates the DataGrid's built-in aggregate functionality by displaying footer aggregate values in the Freight column.
Aggregates in the Blazor DataGrid are displayed in the footer, group footer, and group caption sections. The GridAggregates component provides configuration options for defining aggregate behavior.
The built-in aggregate types supported are:
- Sum - Calculates the total sum of values
- Average - Calculates the average value
- Min - Identifies the minimum value
- Max - Identifies the maximum value
- Count - Counts total records
- TrueCount - Counts boolean true values
- FalseCount - Counts boolean false values
In this demo, the FooterTemplate displays multiple aggregates in the DataGrid footer:
The Sum aggregate is displayed in the Freight column's first aggregate row. Configure this by setting the Type and Field properties to Freight. Within the
FooterTemplate, access the sum value via SumValue.Sum, where SumValue is the implicit Context parameter. The value is formatted using the Format property (C2).The Average aggregate is displayed in the Freight column's second aggregate row. Set the
TypeandFieldproperties to Freight. Access the aggregate value via AverageValue.Average, where AverageValue is the implicit Context parameter. The value is formatted according to theFormatproperty value (C2).
For more detailed information about aggregates, refer to the aggregates documentation.