Smart GWT how to select an item in ComboBoxItem

I have what it seems to be a really simple problem, but somehow it is not. SmartGwt has a way to make something easy and make it overly complicated!

I have a ComboBoxItem populated by LinkedHashMap. All I want to do is the ability to programmatically select a string / value to display. In a simple GWT, it will be something like:

listBox.setSelected (1)

I searched and searched, and I went up empty. Please, help!

+3
source share
2 answers

Suppose your card has values ​​such as

    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
+3
source

You can set the value for the Combobox dropdown via setValuMap (String array [])

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

combox. setValue (String value).

comboBoxItem.setValue( "" );

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

+2

Source: https://habr.com/ru/post/1777249/


All Articles