Kwame
Kwame

Reputation: 1097

Smart GWT how to select item in ComboBoxItem

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!!!

Upvotes: 3

Views: 12237

Answers (2)

Karthikeyan
Karthikeyan

Reputation: 526

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

Upvotes: 2

aruns
aruns

Reputation: 418

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

Upvotes: 3

Related Questions