PDA

View Full Version : Datapointer to Datapath?


tspratt
12-30-2003, 05:08 PM
My goal is to allow users to navigate a deep dataset using a tree control(working fine), and when they select a node, to display some child nodes using a replicating view.

I can find the appropriate data node and set a datapointer (using a recursive function) to it just fine.

But how do I set a *datapath* on the replicating view so it will display my child nodes?

My replicating view works fine with a straight-up dataset because the xpath can be hard coded, but I can't hard code an xpath because my data is arbitrarily deep.

I have attached an example lzx. I want to be able to click an object row and have it display the child attribute nodes.

Thanks in advance for any ideas. (I am using the 2.0 beta if that is any benefit)

Tracy Spratt

adam
01-08-2004, 08:34 AM
Tracy,
This sort of thing is exactly why we have made public the classes that represent data in Laszlo, as of 2.0

The relevant classes here are LzDataNode, LzDataElement and LzDataText, which you should peruse in the reference.

In this case, you can add the data node directly to the datapath for the attribute viewer. Here's how I modified your program:

<canvas>
<debug y="100"/>
<dataset name="testdata">
<object id="o1" name="one">
<attribute atid="a2" value="red"/>
<object id="o2" name="two">
<attribute atid="a1" value="5"/>
<attribute atid="a2" value="blue"/>
</object>
<object id="o4" name="four">
<attribute atid="a3" value="no"/>
<attribute atid="a4" value="512"/>
<attribute atid="a5" value="fred"/>
<object id="05" name="five"/>
</object>
</object>
</dataset>

<datapointer id="dpObject" xpath="testdata:/object[1]/object[3]" />

<simplelayout axis="y" />
<view datapath="testdata:/object[1]/object" clickable="true">
<method event="onclick">
debug.write(this.textid.getText())
parent.viewAttributes.datapath.setPointer( this.datapath.p );
</method>
<simplelayout axis="x" spacing="3"/>
<text name="textid" datapath="@id"/>
<text name="textName" datapath="@name">

</text>
</view>
<view name="viewAttributes" x="20" datapath="">
<simplelayout/>
<view datapath="attribute">
<simplelayout axis="x"/>
<text datapath="@atid"/>
<text datapath="@value"/>
</view>
</view>
</canvas>