yoDon
08-29-2004, 09:26 AM
I'm trying to procedurally access a specific tree node in a nested tree.
I know the index-path to the node (eg. 2.4.3.1 = Root/tree[2]/tree[4]/tree[3]/tree[1]).
The tree was built dynamically from a dataset:
<tree id="TreeRoot" datapath="Dp:/Root/" showroot="false">
<tree datapath="Branches/Branch" text="$path{'@Name'}">
<tree datapath="Leaves/Leaf" text="$path{'@Name'}"/>
</tree>
</tree>
My problem is that I can't find the child tree nodes.
I tried writing a simple test method that would grab the indexed child of of a tree node
<method name="GetTreeChild" args="index">
return this.TreeRoot.subviews[ index ];
</method>
When I started playing with my GetTreeChild method, I discovered that the tree nodes don't seem to be direct subviews of the TreeRoot. I then tried writing a recursive search to look for the tree nodes under all descendents of the TreeRoot, but (a) that seems like an inefficient way to find a item with a known path and (b) I couldn't get it to work regardless of efficiency.
Has anyone put together a procedural select method for trees?
-Don
ps. In case it helps, in the actual implementation each tree node also has a Guid attribute that I had originally hoped to pass to the selection method. When I couldn't find any way to do attribute=value selection of tree nodes, I reworked the server to also provide the index-path to the node. Now I have both bits of data available but no success with either approach.
I know the index-path to the node (eg. 2.4.3.1 = Root/tree[2]/tree[4]/tree[3]/tree[1]).
The tree was built dynamically from a dataset:
<tree id="TreeRoot" datapath="Dp:/Root/" showroot="false">
<tree datapath="Branches/Branch" text="$path{'@Name'}">
<tree datapath="Leaves/Leaf" text="$path{'@Name'}"/>
</tree>
</tree>
My problem is that I can't find the child tree nodes.
I tried writing a simple test method that would grab the indexed child of of a tree node
<method name="GetTreeChild" args="index">
return this.TreeRoot.subviews[ index ];
</method>
When I started playing with my GetTreeChild method, I discovered that the tree nodes don't seem to be direct subviews of the TreeRoot. I then tried writing a recursive search to look for the tree nodes under all descendents of the TreeRoot, but (a) that seems like an inefficient way to find a item with a known path and (b) I couldn't get it to work regardless of efficiency.
Has anyone put together a procedural select method for trees?
-Don
ps. In case it helps, in the actual implementation each tree node also has a Guid attribute that I had originally hoped to pass to the selection method. When I couldn't find any way to do attribute=value selection of tree nodes, I reworked the server to also provide the index-path to the node. Now I have both bits of data available but no success with either approach.