Example of Group and Caption Aggregate in ASP.NET MVC Data Grid Control
This sample demonstrates Aggregate functionality of the Grid. In this sample, “Energy Produced” column will displays their sum
aggregate value in group footer, as well as the min
and max
aggregate value in group caption.
The Grid supports displaying aggregates in the footer, group footer and group caption.
The aggregate configurations can be provided by the
Aggregates
property.
The built-in aggregates are,
Sum
Average
Min
Max
Count
TrueCount
FalseCount
Custom
- Requires theCustomAggregate
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 Energy Produced column and
GroupCaptionTemplate
property is used to display the group caption aggregation.
To enable group footer aggregation for Energy Produced column, the Sum
aggregate type is used by setting the
type
and field
property to EnergyProduced, which will be used to perform the aggregation.
The aggregate value is accessed inside the
groupCaptionTemplate
using its Type
name (${Sum}
).
To enable group caption aggregation for Energy Produced column, the Max
aggregate type is used by setting the
Type
and Field
property is set as EnergyProduced which will be used to perform the aggregation.
The aggregate value is accessed inside theGroupCaptionTemplate
using its
Type
name (${Max}
).
In this sample, GroupCaptionTemplate
to show the multiple aggregate values.
The template expression should be provided inside ${...}
the interpolation syntax.
For more details on the row template feature, refer to this documentation section.