开发者

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!

开发者_JAVA技巧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!!!


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


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜