Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by ez on Apr 28, 2009 03:54
open dhtmlx forum
How to iterate over selected and filtered rows?

Hi!

My function:

for(var i = 0; i<sel_ar.length;i++) {
                    s1+=parseFloat(this.cells(sel_ar[i],3).getValue());    
                    $("#s1").html(s1);    
                }    

set sum of selected rows inside s1 element, but this sum includes all selected rows - also those one not included in current filter.

How can I check if some cell is visible in current filter?
Answer posted by dhxSupport on Apr 28, 2009 14:16

To iterate over all filtered rows you can use row's indexes:

for (var i=0; i<mygrid.getRowsNum()-1; i++){
        s1+=parseFloat(mygrid.cellByIndex(i,3).getValue());
        $("#s1").html(s1);
}

but it become quite complicated if you need to take in account both selected and filtered rows in the same time.

>>How can I check if some cell is visible in current filter?
You can try to use next check

if (this.getRowIndex(id)==-1) continue; //if row index can't be located - row not not included in current filter