Kendo – Grid – Custom Aggregate in FooterTemplate

aggregatesgridkendo-uitemplates

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.

Best Answer

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');
}
Related Topic