set Value for all Children

I have a TreeGrid (2.5) with rather big trees, up to 30k Records, with paging and smartxmlparsing enabled.

Each record has a checkbox at the first column.

Requirement is: when checking the checkbox at a parent node, all children nodes need to be checked as well.

What i’m doing now is looping through all children of the node (using getAllSubItems) and set the value like this: vTreeGrid.cells(vCheckedChilds[i],0).setValue(1);

This works as expected, but it is way too slow, especially when the tree isn’t fully parsed yet.

Is there a better/easier way to do this?

Peter

Are sub rows loaded\rendered before you calling setValue() method?

If rows where loaded and rendered (they are opened), there is no way to improve performance.

Hi,

rows are loaded implicitly by traversing through the treegrid (using .cells in a loop).

I guess the question here is: does a “setValueSubItem” Method or alike exist? Or a (hidden?) setting which speeds up the traversing?

Peter

To detect if row has children you can use hasChildren() method
docs.dhtmlx.com/doku.php?id=dhtm … aschildren
To get ids of sub item you can use docs.dhtmlx.com/doku.php?id=dhtm … etsubitems

You can find list of all available treeGrid API methods here docs.dhtmlx.com/doku.php?id=dhtm … _toc_alpha

This is what i do at the moment:

   // if check row has childs we have to check them as well
   var vCheckedChilds = vTreeGrid.getAllSubItems(pRowId).split(",");
   if (vCheckedChilds[0]!="")
   {
     //console.time("loop Children");
     var vCheckedChildsLength = vCheckedChilds.length;
     for(var i=0; i<vCheckedChildsLength; i++)
     {
       if (pState == true)
       {
         vTreeGrid.cells(vCheckedChilds[i],0).setValue(1);
         gCheckboxArray[vCheckedChilds[i]] = vCheckedChilds[i];
       }
       else
       {
         vTreeGrid.cells(vCheckedChilds[i],0).setValue(0);
         gCheckboxArray[vCheckedChilds[i]] = "";
       }
     }
   }

With 2000 records it takes about 15sec, which is way too slow.
With 30k records it takes even longer (no surprise here).

Is there a faster way to do this?

The fastest way is to update rows on the server side, remove all rows from treeGrid and load the again.
Check example here dhtmlx.com/docs/products/dht … fresh.html