Hi again,
There is a possibility in footer to show the total summatory of a column (without filter) and a summatory of a filtered rows at the same time?
Thanks in advanced
You can have custom code which will summ vaues in grid and place such value in some cell of footer and use #stat_total to show sum of filtered rows.
mygrid.load(url,function(){
var sum=0;
mygrid.forEachRow(function(id){
summ+=mygrid.cells(id,3).getValue()*1;
});
mygrid.attachFooter(","+summ+",#stat_total");
});
In case of treegrid it will be #stat_tree_total
Understood.
But If I load again the php which generate the treegrid xml when I filter, the treegrid will be loaded twice, isn´t it?
Thanks again.
the treegrid will be loaded twice, isn´t it?
,#stat_total");
in case of above code - yes, but you can move attachFooter outside of on-load code
mygrid.attachFooter(",
mygrid.load(url,function(){
var sum=0;
mygrid.forEachRow(function(id){
summ+=mygrid.cells(id,3).getValue()*1;
});
document.getElementById(âsome1â).innerHTML=âsummâ;
});
In such case the footer will be attached only once
Hi, thanks for your last answer.
A last problem, the url parameter must have the php which load de hole treegrid, isnât it?
Thanks
Yes, in above scenario - url - path to script|xml, which will load full tree grid. ( it impossible to calculate total value if not all data loaded )
Sure, but the treegrid had been loaded before at the fist time, then I filter and the treegrid is loaded again. This is what I asked before, the treegrid is loaded twice and the rows are repeated.
The code snippet above need to be applied when grid loaded first time, it can be rewritten in more agnostic way as
grid = newâŚ
grid.attachFooter(",
grid.attachEvent(âonXLEâ,function(){
var sum=0;
mygrid.forEachRow(function(id){
summ+=mygrid.cells(id,3).getValue()*1;
});
document.getElementById(âsome1â).innerHTML=âsummâ;
});
⌠other initâŚ
the code attached to onXLE event will fire when data loaded in grid in any possible way
Hi there,
I put the code when the grid is loaded first time, but I get that error:
c is null
 dhtmlxtreegrid/dhtmlxgrid.js
Line 882
Working sample sent by email.
Thanks for your sample,
Itâs exactly how I had uesd it, but that code not work in a treegrid and a filterby function filter.
Similar sample, but for TreeGrid sent by email
Ok, it works perfectly, but one issue:
If I filter in the second column (#text_filter) by 3, the summatory isnât 26.56 (13.28 x 2), but 254.86. The system adds all the rows.
Itâs a bug?
TreeGrid can use two types of counters
#stat_tree_total - sum of all values in column
#stat_tree_total_leaf - sum of values on last level only
Perfect!!!
Thank you for your help and patience,
Charly