PDA

View Full Version : Help with dynamic comboboxes


rcheramy
11-09-2004, 05:03 PM
I'm stumped on how to update a display based on the value selected in a combobox.

I've simplified this down to the raw basics. I know I'm very close but just can't see what I'm missing.


<canvas width="900" height="500">
<dataset name="subs">
<xml>
<subscription id="1111">
<listname>Christmas Deals</listname>
<subscriberCount>1500</subscriberCount>
</subscription>
<subscription id="1212">
<listname>Monthly Deals</listname>
<subscriberCount>1139</subscriberCount>
</subscription>
<subscription id="1313">
<listname>Spring Deals</listname>
<subscriberCount>2192911212</subscriberCount>
</subscription>
</xml>
</dataset>
<simplelayout axis="y" spacing="5"/>
<view width="500" height="50">
<simplelayout axis="x" spacing="5"/>

<combobox defaulttext="pick one" id="sublist" width="200">
<method event="onselect">
datazone.setDatapath('subs:/xml/subscription[@id='+sublist.value+']')
</method>

<textlistitem width="${parent.width}" name="dynList" datapath="subs:/xml/subscription/" text="$path{'listname/text()'}" value="$path{'@id'}"/>
</combobox>
<text text="${'value: '+sublist.value}"/>

</view>

<view id="datazone" width="${(parent.width)-10}" datapath="subs:/xml/subscription[@id='1313']">
<simplelayout axis="y"/>
<view width="300">
<simplelayout axis="x"/>
<text text="Listname:"/>
<text text="$path{'listname/text()'}"/>
</view>
<view width="300">
<simplelayout axis="x"/>
<text text="Subscriber Count:"/>
<text text="$path{'subscriberCount/text()'}"/>
</view>
</view>
</canvas>

rcheramy
11-10-2004, 01:50 PM
In searching through the forums I came across this:

http://www.laszlosystems.com/developers/community/forums/showthread.php?s=&threadid=612

Basically I want to do the same thing but from a combobox instead of multiple views.

rcheramy
11-10-2004, 02:12 PM
Simple mistake... the onselect should be on the textlistitem rather than on the combobox... (of course it's real clear now... :) )

For the benefit of any readers... here is the modified working code:



<canvas width="900" height="500">
<dataset name="subs">
<xml>
<subscription id="1111">
<listname>Christmas Deals</listname>
<subscriberCount>1500</subscriberCount>
</subscription>
<subscription id="1212">
<listname>Monthly Deals</listname>
<subscriberCount>1139</subscriberCount>
</subscription>
<subscription id="1313">
<listname>Spring Deals</listname>
<subscriberCount>2192911212</subscriberCount>
</subscription>
</xml>
</dataset>
<simplelayout axis="y" spacing="5"/>
<view width="500" height="50">
<simplelayout axis="x" spacing="5"/>

<combobox defaulttext="pick one" id="sublist" width="200">
<textlistitem width="${parent.width}" name="dynList" datapath="subs:/xml/subscription/" text="$path{'listname/text()'}" value="$path{'@id'}">
<method event="onselect">
datazone.datapath.setPointer( this.datapath.p );
</method>
</textlistitem>
</combobox>
<text text="${'value: '+sublist.value}"/>

</view>

<view id="datazone" width="${(parent.width)-10}" datapath="subs:/xml/subscription[@id='1313']">
<simplelayout axis="y"/>
<view width="300">
<simplelayout axis="x"/>
<text text="Listname:"/>
<text text="$path{'listname/text()'}"/>
</view>
<view width="300">
<simplelayout axis="x"/>
<text text="Subscriber Count:"/>
<text text="$path{'subscriberCount/text()'}"/>
</view>
</view>
</canvas>