PDA

View Full Version : combobox item selection


mallesh
11-19-2003, 06:43 AM
Hi Antun,

How do i select the items in the combobox by without clicking on the button next to the combobox.like, when ever i want to query the database by passing item value in the combobox, first i have to select the item, and then click the the button, next to the combobox.But i don't need button next to the combobox, but by selecting the item in the combobox, item value should pass dynamically, by doRequest() method.

i tried with "onselect" event in the combobox.
but that does not work (I am using LPS1.0.1)

Thanks
Mallesh

antun
11-19-2003, 09:32 AM
There is no onselect event handler defined for the combobox. The underlying events system in LZX means that you can bind methods to events of different views. I wrote my own combobox class that extended combobox, and bound a new method (doSelect) to the onselect event that is sent out when an item is clicked. To figure this all out I looked at the code for combobox, which is in WEB-INF/components/redmond/combobox.lzx. (Actually I made a copy of the combobox.lzx file, renamed all the classes in it so that I didn't get any class redefinition errors from the compiler, and added some debug.write() statements to hack it).

Then I added another delegate that listened out for a change in the text field and read that value:


<canvas debug="true">

<dataset name="namelist" >
<item>Susan</item>
<item>Bob</item>
<item>Carol</item>
<item>Steven</item>
<item>Anne</item>
</dataset>


<class name="mycombobox" extends="combobox">
<method event="oninit">
this.selectDel = new LzDelegate(this,'doSelect',
this.cblistview,"onselect");
</method>

<method name="doSelect">
this.getTextDel = new LzDelegate( this, 'returnText',
this.top.field, 'ontext' );
</method>

<method name="returnText">
this.getTextDel.unregisterAll();
debug.write( this.top.field.getText() );
</method>

</class>

<mycombobox x="10" y="50" width="152" shownitems="4"
itemfield="nameList:/item/text()"
datapath="nameList:/item[1]/text()"
name="mycombo" >
</mycombobox>

</canvas>


-Antun