hi,
we have a treegrid with 1 column which has a filter box
we are trying to loop through the grid to get all items. however we are finding that if we add criteria into the filter box, it only loops through the visible rows. we want it to loop through all rows not just the visible ones
this is the loop code we are using:
grid._h2.forEachChild(0,
function(row)
{
id = row.id;
rowArray[rowArray.length] = id;
});
thanks
If you not using smart-rendering or smart-xml-parsing modes, you can try to use
mygrid.forEachRow(code);
It will loop from all rows in treegrid.
There is no stable way to loop through all rows in filtered treegrid , the next code will work for latest TreeGrid, but it based on inner vars, so there can be problem in future updates
var h = grid._f_rowsBuffer||grid._h2; //takes saved hierarchy or actual one
h.forEachChild(0,
function(row)
{
id = row.id;
rowArray[rowArray.length] = id;
});
yes we are using smart xml parsing. so is there no stable way in that case?
yes we are using smart xml parsing.
The second solution, in above post, will work for such init, but it is based on inner variables - so it may be changed in next versions.
but as you said this is not stable and therefore we would not like to have to change code in a future version, as if we forget this could temporarily cause many problems for our customers.
we will have to come up with our own work around.
can your company come up with a function to handle this in a stable way?
You can use code as
var hierarchy;
grid.load(url,function(){
hierarchy = grid._h2;
});
and use hierarchy to iterate through rows
hierarchy.forEachChild(0,
with above code snippet hierarchy will be saved just after data loading and will contain data about all rows in unfiltered grid structure
thanks very much, and is this stable through future versions?
Yes, it uses only public properties - so this functionality will not be affected by future updates
hi we have just noticed a problem with this is that if we want to loop through the grid after items have been dragged to it, then it is not looping through the newly added rows
do you have any fix for this?
thanks
no?
Which version of grid you are using?
Issue can’t be reconstructed for grid 2.1 ( there was similar issue in older versions of grid )