Kendo - Grid - Custom Aggregate in FooterTemplate

James picture James · Nov 16, 2012 · Viewed 7.7k times · Source

My understanding is that Kendo does not support custom aggregates but you can call a function in the footerTemplate. That function then can provide calculations on the data and can even reference kendo defined aggregates. So, for example,

footerTemplate: "<div><b>Range</b> #= computeRange()#</div>"

If this is correct, how would you write the function computeRange? It would use max-min aggregates.

Also, how would you write a computeMedian function?

Thanks in advance for your help.

Answer

Deepu picture Deepu · May 11, 2013
function computeRange(){
    var bal         =   0;
    var ds          =   $("#itemcode_grid").data("kendoGrid").dataSource;
    var aggregates  =   ds.aggregates();
    if(aggregates.total_balance)
        bal         =   aggregates.total_balance.sum;
    else
        bal         =   0;
    return kendo.toString(bal,'n2');
}