Skip to main content

How to set the selected item of the dojo.combobox dynamiclly ?

3 replies [Last post]
yummychen
Offline
Joined: 2008-04-07
Points: 0

Hi :
How can i to set the selected item of the dojo.combobox dynamically ?
Can i set some properties to this widget ?

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
gmurray71
Offline
Joined: 2003-07-31
Points: 0

In your model you will need to assign an id to the items you want to select.

I've updated the model pages to show what you are doing:

http://wiki.java.net/bin/view/Projects/jMakiComboxModel for the format:

In a nutshell you may have:

[
{ id : 'al', label : 'Alabama', value : 'AL'},
{ id : 'ca', label : 'California', value : 'CA'},
{ id : 'ny', label : 'New York', value : 'NY', selected : true},
{ id, 'tx', label : 'Texas', value : 'TX'}
]

To select 'ca' you would:

jmaki.publish("/dojo/dijit/combobox/select", {
targetId : 'ca'}
});

Let me know if that doesn't work.

-Greg

yummychen
Offline
Joined: 2008-04-07
Points: 0

Hi Greg :
Thanks.
This article show that i can use the selected attribute to set the selected item : [u]https://ajax.dev.java.net/usingFaces.html[/u]
But it doesn't work.
Do you know why i can'y use the selected attribute?
Thanks again.

yummychen
Offline
Joined: 2008-04-07
Points: 0

I have review the code of component.js and find a solution.
I can use the args attribute to set the selected item of dojo.combobox.
EX: value="[
{id : 'ft', label : 'FT', value : 'ft'},
{id : 'assyYield', label : 'AssyYield', value : 'assyYield'},
{id : 'assySpc', label : 'AssySPC', value : 'assySpc'},
{id : 'cp1', label : 'CP1', value : 'cp1'},
{id : 'cp2', label : 'CP2', value : 'cp2'},
{id : 'wat', label : 'WAT', value : 'wat'}
]"
args="{selected : 'cp1'}" />