Smart GWT how to select item in ComboBoxItem

Kwame picture Kwame · Nov 28, 2010 · Viewed 11.9k times · Source

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

Answer

aruns picture aruns · Nov 29, 2010

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