Telerik Extensions for ASP.NET MVC

Version Q2 2012, released 06/07/2012

Server Aggregates

 Product NameUnit PriceUnits On OrderUnits In Stock

Units In Stock: 0 (Count: 5)

 Chef Anton's Gumbo Mix$21.3500
 Alice Mutton$39.0000
 Thüringer Rostbratwurst$123.7900
 Gorgonzola Telino$12.50700
 Perth Pasties$32.8000

Units In Stock: 3 (Count: 1)

 Sir Rodney's Scones$10.00403

Units In Stock: 4 (Count: 2)

 Louisiana Hot Spiced Okra$17.001004
 Longlife Tofu$10.00204

Units In Stock: 5 (Count: 1)

 Rogede sild$9.50705

Units In Stock: 6 (Count: 2)

 Northwoods Cranberry Sauce$40.0006
Displaying items 1 - 10 of 77

About this example ASPXRazor

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

The following aggregates are supported:

  • Average
  • Count
  • Min
  • Max
  • Sum

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>
                <%
            })
    

Interested in HTML5 and mobile-powered ASP.NET MVC apps?

Experience the next generation UI and framework for ASP.NET MVC development by downloading trial evaluation copy of Kendo UI Complete for ASP.NET MVC. Jumpstart your development with the available learning resources.

The differences between Telerik MVC Extensions and Kendo UI Complete for ASP.NET MVC, and their licensing models are explained here and here.

If you have any questions, do not hesitate to contact us at sales@telerik.com.

Other Demos: