« Return to Thread: addOptions - format the text/value shown in listbox (select)

RE: addOptions - format the text/value shown in listbox (select)

by mikewse :: Rate this Message:

Reply to Author | View in Thread

Hej Andreas,

> I have a java-method returning a collection with javabeans
> with countries
> which have an id and a name
> something like ('SE', 'Sweden), ('DK', 'Denmark')
>
> <snip>
>
> The value in the listbox is the "id" of the country: SE, DK, etc
>
> I would like to format the text (shown to the user in the
> listbox), so
> more than the country name is shown.
> For example, I would like the result to be
> 'SE Sweden', 'DK Denmark' in the listbox.
> Is there a way with addOptions to do this?

You can supply functions instead of property names, so something
like this should fix your problem:
  dwr.util.addOptions('mylistbox', data, 'id',
    function(x){return x.id+" "+x.name;});

Best regards
Mike (Göteborg ;-)

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@...
For additional commands, e-mail: users-help@...

 « Return to Thread: addOptions - format the text/value shown in listbox (select)