Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Anoop Isaac on Mar 14, 2008 04:02
open dhtmlx forum
custom formulae

I would like to know in treegird , is it possible to have custom formuale to display custom value on summary rows.THis custom valued will generated by applying custom formulae on child cells.
Answer posted by Support on Mar 14, 2008 07:53
Built in math allow only "sum" as aggregation function.

In case of "auto-calculated-values-in-footer", it possible to extend existing functionality and add custom formula, it not so simple but possible

For example to add sum(x^2) next code need to be added in project

dhtmlXGridObject.prototype._in_header_stat_sum2=function(t,i,c){
    var calck=function(){
        var summ=0;
        this.forEachRow(function(id){
             // id - id of row
             // i - index of column
             summ += Math.pow(this.cells2(id,i).getValue(),2);   // main formula
        });
        return summ;
    }
    this._stat_in_header(t,calck,i,c);   //default call, to attach all necessary handlers
}


now you can use your formula by specifing in header|footer

grid.attachFooter("A,B,#stat_sum2,C");