DHTMLX Docs & Samples Explorer

Built-in Iterator

This way of TreeGrid iteration has the following characteristic:

  • Used parameter - row ID;
  • Order of iteration is not equal to the current rows order in the grid (basically, it is equal to the adding order of rows to the grid, but it can be inconsistent);
  • In case of paging or smart rendering mode - all rows parsed at the current moment will be affected;
  • In case of applied filtering - all rows in the grid (including filtered out ones) will be included in iteration;
  • In case of TreeGird - all rows will be processed, including those in closed branches.
          treegrid.forEachRow(function(id){ // function that gets row id as an incoming argument
                  // here id - row ID
               do_something_with_row(id);
          })

You can loop from all child-rows of some row in treegrid as

treegrid._h2.forEachChild(parent_id,function(element){
//element.id - id of child row
//element.parent.id - parent id
do_something_with_row(element.id);
});

where parent_id - id of rows, against which functionality will be executed.