PDA

View Full Version : Simple question for tree view control


Tanmay
09-20-2009, 10:24 PM
I am a little confused about the tree view control as I have never used it earlier, so I have a question which is simple for all geeks out here :). Below is the sample xml which I am trying to make a tree of-

<table tname="alphabet">
<row val="abc" type="menu1" parent=""/>
<row val="def" type="screen1" parent="menu1"/>
<row val="ghi" type="screen2" parent="menu2"/>
<row val="jkl" type="screen3" parent="menu1"/>
<row val="mno" type="menu2" parent=""/>
<row val="pqr" type="menu3" parent=""/>
</table>

As you can notice the relation is defined in attribute "parent", so if "def" has a parent="menu1" then it sud come under that node. Here is my try with it -


<dataset name="ds" src="tree.xml"/>
<tree visible="true" name="tv" width="160" height="200" datapath="ds/table/"
text="$path{'@val'}" multiselect="false" closesiblings="false">
<tree width="160" height="20" datapath="*" text="$path{'@val'}"
isleaf="${this.datapath.xpathQuery('@parent') != ''}" ></tree>
</tree>

The issue with the above code is it is not showing the hierarchy correctly and all elements appear in same level. So guys please help me out in how to use the "parent" atribute to get the relation going and tree showing it correctly...

tglines
09-22-2009, 11:37 AM
The tree will show the same structure as your dataset. You didn't say how the dataset was generated but if you change its structure to reflect what you would like to see in the tree, it will work.

Maybe something like this:

<table name="alphabet">
<menu val="abc">
<screen val="def"/>
<screen val="jkl"/>
</menu val="mno">
<menu>
<screen val="ghi"/>
</menu>
<menu val="pqr"/>
</table>