This sample demonstrates Aggregate functionality of the Grid. In this sample, both “Unit In Stock” and “Discontinued” columns are displayed their aggregate value in group footer. “Unit In Stock” column displayed its aggregate value in group caption also.
The Grid supports aggregates which will be displayed at the footer, group footer and group caption of the Grid.
The aggregate configurations can be provided by the
aggregates
property.
The built-in aggregates are,
Sum
Average
Min
Max
Count
TrueCount
FalseCount
Custom
- Requires the
customAggregate
property to perform the aggregation.
The custom aggregate value can be accessed inside template using the key Custom
In this demo, the
groupFooterTemplate
property is used to display the group footer aggregation for the Unit In Stocks and Discontinued columns and
groupCaptionTemplate
property is used to display the group caption aggregation for the Unit In Stocks column.
To enable group footer aggregation for Unit In Stocks column, the Sum
aggregate type is used by setting the
type
and the
field
property is set as UnitsInStock which will be used to perform the aggregation.
The aggregate value is accessed inside the
groupFooterTemplate
using its
type
name (Sum
).
To enable group caption aggregation for Unit In Stocks column, the Max
aggregate type is used by setting the
type
and
field
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 (Max
).
Injecting Module:
Grid component features are segregated into individual feature-wise modules. To use aggregate feature, we need to inject
Aggregate
into the provide
section. Since grouping feature is required
to show group aggreations, we also need to inject Group
module.