Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by c. bernstein on Dec 08, 2009 07:03
open dhtmlx forum
Dynamically Expanding a Tree Node (from code, without user click)

Is there a way, when loading a tree grid whose child nodes will be expanded only when the user clicks the "+" next to the parent rows, to dynamically expand several of the parent nodes, such that they will already be expanded when the tree grid is displayed on the page? For instance, if the following tree was to be displayed:
1 Level1-1
2 Level2-1
3 Level2-2
4 Level1-2
5 Level2-3
6 Level1-3
7 Level2-4

Normally you would see

+ Level1-1
+ Level1-2
+ Level1-3

Is there a way to specify that row 1 should be expanded such that the grid looks as follows when it is first displayed on the page:

- Level1-1
Level2-1
Level2-2
+ Level1-2
+ Level1-3

Thanks in advance!

chava bernstein
Answer posted by Alex (support) on Dec 08, 2009 08:17

You can open a branch using openItem method:

grid.loadXML(url,doAfterLoading);

function doAfterLoading(){

   grid.openItem(itemId);

}

Or you can define opened rows directly in the xml by open="1" attribute:

<row id=".." open="1">...

Answer posted on Dec 09, 2009 05:59
Is the itemId the same thing as the rowId?
Answer posted by Alex (support) on Dec 09, 2009 06:47
Yes, it is.