PDA

View Full Version : How to create a Dynamic Tree Structure


Anusha
03-29-2004, 03:09 AM
Hi

I've a requirement that i need to create a Tree like structure for my application..I saw the examples given in the laszlo samples for creating a Tree structure .But in those samples I found that the data in the tree structure are pre-defined one..But for my application the data is a dynamic one..i.e it means the data should be generated on the fly...So is it possible to create a Dynamic Tree Structure as per my requirement???.can anybody give me a solution or an idea


--Anush

antun
03-29-2004, 12:41 PM
At the moment the tree component will update only at init time, so you can make a request for dynamic data, and the tree will be different every time the applications starts.

However the tree component currently does not update at run-time when the data it is bound to changes. There is a bug filed on this issue, and a future release will probably support this.

In the meantime, you could always create nodes on the tree at run-time, for example:


<canvas width="800" height="600" debug="false">

<!-- <debug x="400" width="400" height="400" /> -->

<include href="lz/tree.lzx" />

<dataset name="ancestors">
<hobbit name="Frodo">
<hobbit name="Drogo">
<hobbit name="Fosco" grandparent="true" />
<hobbit name="Bolger, Ruby" grandparent="true" />
</hobbit>
<hobbit name="Brandybuck, Primula">
<hobbit name="Brandybuck, Gorbadoc" grandparent="true" />
<hobbit name="Took, Mirabella" grandparent="true" />
</hobbit>
</hobbit>
</dataset>

<!-- data replicated tree -->
<tree datapath="ancestors:/" icon="null" showroot="false" name="mytree"
open="true">
<tree name="t" datapath="*" icon="null" text="$path{'@name'}"
open="true"
isleaf="$path{'@grandparent'}"/>
</tree>


<view x="300" y="10">
<simplelayout axis="y" spacing="10" />
<edittext name="txt" width="175">New Hobbit</edittext>

<button>Create new node.
<method event="onclick">
var f = mytree.t.subViews[1].subviews[0];
var newNode = new tree ( f, { icon:null,
text:parent.txt.text,
isleaf:true } );
</method>
</button>
</view>

</canvas>


... it just won't be as smooth as merely manipulating XML nodes in a dataset.

-Antun