Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by ez on Mar 05, 2009 02:14
open dhtmlx forum
TreeGrid [=sum] and filters problem

Hello!

I have a treegrid with subsumes calculated by [=sum] feature.

But, when I add filter on data the subsums are not being updated.

I try to call:

treegrid .callEvent("onGridReconstructed",[])

... after filtering but with no success

How can I force [=sum] cell recalculation?
Answer posted by Support on Mar 06, 2009 03:00
Unfortunately there is no clear way to trigger math recalculation.

You can try to add the next code 
mygrid.attachEvent("onFitlerEnd",function(){
     mygrid.callEvent("onXLE",[]);
     return true;
})

as side effect, it will double call any code attached to onXLE event , but will recalculate all "=sum" math in treegrid
Answer posted by ez on Mar 06, 2009 03:43
I try to call onXLE but this solution has an issue - aflter onXLE content of filter fild are cleared (but filter exists).

So, I find other way:

mygrid.attachEvent("onFilterEnd",function(){           
            for (var i=0;i < this._aggregators.length;i++){
                if (this._aggregators[i]) this._h2.forEachChild(0,function(el){
                    if (el.childs.length!=0){
                        var ed=this.cells(el.id,i);
                        ed.setValue(this._calcSCL(ed.cell))
                        }
                },this)
            }
            return true;
        });

and this one works just fine