Smart GWT how to select item in ComboBoxItem

11,983

Solution 1

Suppose your map has values like

    items.put(1,"a");
    items.put(2,"b");
ComboBoxItem listBox = new ComboBoxItem();
listBox.setValueMap(items);

Then

listBox.setValue(1) will display "a" in listBox
listBox.setvalue(2) will display "b" in listBox

Solution 2

You Can set value's for drop down in Combobox item through setValuMap(String array[])

String []valueMap = {"A","B"};
comboBoxItem.setValueMap(valueMap);

this will set the value in string array to combox box. You can set value programmatically through setValue(String value) function.

comboBoxItem.setValue("A");

http://www.smartclient.com/smartgwt/javadoc/com/smartgwt/client/widgets/form/fields/ComboBoxItem.html

Share:
11,983
Kwame
Author by

Kwame

Updated on June 05, 2022

Comments

  • Kwame
    Kwame almost 2 years

    I have what seems like it should be a really simple problem, but somehow it is not. SmartGwt has a way of taking something easy and making it overly complicated!

    I have a ComboBoxItem populated by a LinkedHashMap. All I want to do is to be able to programmatically select a row/value to display. In plain GWT, this would be something like:

    listBox.setSelected(1)

    I have searched and searched, and I have come up empty. Please someone help!!!