Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Carl on Mar 04, 2008 13:03
open dhtmlx forum
Adding row to maintain tree structure in "tree" column

Hi,

I have an xTreeGrid with the first column set as type "tree". Loading from XML I create a 3 tier tree in this first column by specifying rows within rows inthe XML definition. How do I use the addRow function to add a new row to the grid but still preserve the tree structure in the first column?

e.g. Say I'm loading a very basic:

<row id="level.1" open="1">
    <cell>LEVEL1</cell>
    <cell>< />

<row id="level2.1" open="1">
    <cell>LEVEL2</cell>
    <cell>< />

<row id="level3.1" open="1">
    <cell></cell>
    <cell>Hello< />
</row>
</row>
</row>

So LEVEL1 will be expandable to have LEVEL2 below it, and LEVEL2 will be expandable with Hello in the 2nd column - how can I use an addRow() call to maintain this LEVEL1/LEVEL2 tree and have another row with a value in the 2nd column?

Thanks!
Answer posted by Support on Mar 05, 2008 08:28
In case of treeGrid addRow command can have 3 additional parameters
    - parent id
    - image
    - child flag ( used in dynamical loading only )


grid.addRow(new_id,[" top level row "," second column value"],null,0); //adding row on top level
grid.addRow(new_id2,[" child row "," second column value"],null,new_id); //adding row as child of new row
grid.addRow(new_id3,[" child row "," second column value"],null,'level2.1'); //adding row as child of existing row