PDA

View Full Version : Procedurally selecting a tree node


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.

yoDon
08-29-2004, 02:57 PM
Hmmm... the List class seems to offer most of selection features I'm looking for. Too bad the tree class doesn't implement (or derive from?) Baselistitem.

It looks like I need to derive my own custom tree class based on the list class. That should also solve my other current question (re:lazy loading) since the LZX refs for the list class talk quite a bit about lazy loading.

-Don