This example shows how to use aggregates in Telerik Grid for ASP.NET MVC which is bound server side.

The following aggregates are supported:

To specify the aggregates for a column use the Aggregates method:

columns.Bound(o => o.UnitsInStock)
        .Aggregate(aggregates => aggregates.Count().Min().Max())

Aggregate results can be displayed in three locations:

  1. In the group header:
    columns.Bound(o => o.UnitsInStock)
            .Aggregate(aggregates => aggregates.Count())
            .GroupHeaderTemplate(result =>
            {
                %>
                    <%= result.Title%>: <%= result.Key %> (Count: <%= result.Count %>)
                <%
            });
    
  2. In the group footer:
    columns.Bound(o => o.UnitsOnOrder)
            .Aggregate(aggregates => aggregates.Average())
            .GroupFooterTemplate(result =>
            {
                %>
                    Average: <%= result.Average%>
                <%
            });
    
  3. In the grid footer:
    columns.Bound(o => o.UnitsInStock)
            .Aggregate(aggregates => aggregates.Count().Min().Max())
            .FooterTemplate(result =>
            {
                %>
                    <div>Min: <%= result.Min%></div>
                    <div>Max: <%= result.Max%></div>
                <%
            })