[Laszlo-dev] Default selection in a combo populated from a dataset

P T Withington ptw at pobox.com
Fri Jun 10 10:45:38 PDT 2005


Yes.  I ran into the same problem:  http://pt.withy.org/ptalk/ 
archives/2005/05/about_that_serverless_app.html

There are 2 issues:  1) all $path values are strings, so you need to  
test for `== 'true'`, and 2) you can't select an item until it is  
inited (so setting selected directly from the datapath happens 'too  
soon').

Try this:

On 9 Jun 2005, at 18:02, Derek Adams wrote:


> I am having trouble finding the correct way to default the selected  
> item in a combo box populated from a dataset.  I tried this:
>
> <canvas debug="true" layout="axis:y">
>  <dataset name="myData">
>   <items>
>    <item value="v1">Value 1</item>
>    <item value="v2" selected="true">Value 2</item>
>    <item value="v3">Value 3</item>
>   </items>
>  </dataset>
>  <combobox editable="false">
>      <textlistitem datapath="myData:/items/item" text="$path{'text 
> ()'}"
>              value="$path{'@value'}"
>

                oninit="this.setAttribute('selected', this.selectMe  
== "true")"


> >
>

          <attribute name="selectMe" value="$path{'@selected'} />
        </textlistitem>


>  </combobox>
> </canvas>
>
> I know there has to be an easy way to do this. Any ideas?
>
> Thanks,
> Derek Adams
>
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com _______________________________________________
> Laszlo-dev mailing list
> Laszlo-dev at openlaszlo.org
> http://www.openlaszlo.org/mailman/listinfo/laszlo-dev
>
>




More information about the Laszlo-dev mailing list