jakeh
08-25-2004, 10:18 AM
I have a list that is populated with data from an XML file. I am running in debug mode and it is returning two values when I select an item (note: it only returns 1 value for the first item selected, after that it returns the former items value and the new items value). Also, it returns it this way wheter i choose to use an onSelect method or onSelected.
Code:
::datalistbox.lzx::
<canvas debug="true">
<dataset name="contactdata" src="contacts.xml" />
<class name="datalistbox" extends="list" width="200" shownitems="5">
<textlistitem datapath="${classroot.path}">
<method event="onSelected">
debug.Write(this.getValue());
</method>
<method event="onData">
var mytxtpath = classroot.txt + "/text()";
var mytxt = this.datapath.xpathQuery( mytxtpath );
this.setAttribute( "text" , mytxt );
var myvalpath = classroot.txt + "/text()";
var myval = this.datapath.xpathQuery( myvalpath );
this.setAttribute( "text" , myval );
</method>
</textlistitem>
</class>
<datalistbox txt="fullname" val="id" path="contactdata:/phonebook/contact/" />
</canvas>
::contacts.xml::
<phonebook>
<contact>
<id>001</id>
<fullname>John A Smith</fullname>
</contact>
<contact>
<id>002</id>
<fullname>John S Smith</fullname>
</contact>
<contact>
<id>003</id>
<fullname>John M Smith</fullname>
</contact>
<contact>
<id>004</id>
<fullname>John R Smith</fullname>
</contact>
<contact>
<id>005</id>
<fullname>John J Smith</fullname>
</contact>
</phonebook>
Thanks for any help with this.
Jake
Code:
::datalistbox.lzx::
<canvas debug="true">
<dataset name="contactdata" src="contacts.xml" />
<class name="datalistbox" extends="list" width="200" shownitems="5">
<textlistitem datapath="${classroot.path}">
<method event="onSelected">
debug.Write(this.getValue());
</method>
<method event="onData">
var mytxtpath = classroot.txt + "/text()";
var mytxt = this.datapath.xpathQuery( mytxtpath );
this.setAttribute( "text" , mytxt );
var myvalpath = classroot.txt + "/text()";
var myval = this.datapath.xpathQuery( myvalpath );
this.setAttribute( "text" , myval );
</method>
</textlistitem>
</class>
<datalistbox txt="fullname" val="id" path="contactdata:/phonebook/contact/" />
</canvas>
::contacts.xml::
<phonebook>
<contact>
<id>001</id>
<fullname>John A Smith</fullname>
</contact>
<contact>
<id>002</id>
<fullname>John S Smith</fullname>
</contact>
<contact>
<id>003</id>
<fullname>John M Smith</fullname>
</contact>
<contact>
<id>004</id>
<fullname>John R Smith</fullname>
</contact>
<contact>
<id>005</id>
<fullname>John J Smith</fullname>
</contact>
</phonebook>
Thanks for any help with this.
Jake