I ran into the same requirement. The telerik system seems to NOT perform any fun with it. So I wrote my own as follows:
Custom Binding in MVC Grid with AJAX loading to use the Aggregates property on the GridModel for populating aggregates (works across pages,etc).
There are 4 key pieces:
1) Modify controller to create an instance of the class that is the same as the type used in the GridModel data enumerable. Populate that new instance with the aggregated values. // pageItems is my paginated, filtered, sorted data. DayBySymbolItem aggregator = new DayBySymbolItem()
{
ClosingMarketValue = pageItems.Sum(a => a.ClosingMarketValue),
Commissions = pageItems.Sum(a => a.Commissions),
Dividends = pageItems.Sum(a => a.Dividends),
GrossPNL = pageItems.Sum(a => a.GrossPNL),
GrossTradeDollars = pageItems.Sum(a => a.GrossTradeDollars),
NetDailyPNL = pageItems.Sum(a => a.NetDailyPNL),
OpeningMarketValue = pageItems.Sum(a => a.OpeningMarketValue)
}; Data = new GridModel<DayBySymbolItem> { Total = totalRecords, Data = pageItems, Aggregates = aggregator },
2) Modify the Grid definition to include a unique class name in the FooterHtmlAttributes for which you want to push an aggregate. NO ClientTemplate is required!
columns.Bound(o => o.NetDailyPNL).Title("Net Daily Profit and Loss")
.Format("{0:c2}").HtmlAttributes(new { Class = "Money" })
.FooterHtmlAttributes(new { Class = "Money NetDailyPNL" });
3) Introduce a new JS function bound to the Grid's "OnComplete" client side event with a single parameter. This lets you grab the aggregate from the Ajax response. Note, don't update your footer or it will get whipped by the OnDataBound. Set the aggregate to a global var.
function ReportAjaxComplete(e) { var result = e.response; if (result) { reportAggregates = e.response["aggregates"]; } }
function ReportLoaded(e) { if (reportAggregates != "") { UpdateAggregates(reportAggregates); } }
4) Modify the OnDataBound to check to see if the aggregates exist, if so call a helper function to update the footer with the data from the aggregates.
function UpdateAggregates(aggs) {
for (var key in aggs) {
$("." + key).text( aggs[key] );
}
}
Done ... (note, I format the aggregates after checking to confirm they are number value).