Example of Group and Caption Aggregate in Blazor DataGrid Component
This sample demonstrates the DataGrid's aggregate functionality. In this sample, the aggregate value of the Units in Stock and Discontinued columns is displayed in the group footer. The aggregate value of the Units in Stock column is also displayed in the group caption.
Category Name | Product Name | Quantity per Unit | Units in Stock | Discontinued |
---|
The Blazor DataGrid supports aggregates which will be displayed at the footer, group footer and group caption of the DataGrid. The aggregate configurations can be provided by using the GridAggregates component.
The built-in aggregates are,
- Sum
- Average
- Min
- Max
- Count
- TrueCount
- FalseCount
In this demo, the GroupFooterTemplate is used for displaying the group footer aggregation for the Units in Stock and Discontinued columns and GroupCaptionTemplate is used for displaying the group caption aggregation for the Unit In Stock column.
To enable group footer aggregation for Units in Stock column, the Sum aggregate type is used by setting it in Type property and Field property value as UnitsInStock which will be used to perform the aggregation. The aggregate value is accessed inside the GroupFooterTemplate
using its Type
name (Unit.Sum) where Unit is an implicit named parameter - Context.
To enable group caption aggregation for Units in Stock column, the Max aggregate type is used by setting it in Type
property and the property is set as UnitsInStock which will be used to perform the aggregation. The aggregate value is accessed inside the GroupCaptionTemplate
using its Type
name (Unit.Max) where Unit is an implicit named parameter - Context.
More information about the Group and Caption aggregate can be found in this documentation section.