GXT (Ext GWT) problem with SimpleComboBox
Asked Answered
C

3

5

When creating a GXT SimpleComboBox (as in the accepted answer here),

    final FormPanel fp = new FormPanel();

    SimpleComboBox<String> combo = new SimpleComboBox<String>();
    combo.add("One");
    combo.add("Two");
    combo.add("Three");
    combo.setSimpleValue("Two"); // I'd like to preselect that value

    fp.add(combo);
    RootPanel.get().add(fp);

my combo box only contains the value "Two". The values "One" and "Three" are completely removed from the combo box. This doesn't happen, when I delete the line combo.setSimpleValue("Two");

I'm using GXT 2.2.3 and GWT 2.2.0 (tested on Linux/Firefox and Linux/Chrome). Is this a bug / did it work in older versions of GXT/GWT, or am I doing something wrong?

Update

I accepted an answer, and it solves the problem: Add the line

combo.setTriggerAction(TriggerAction.ALL);

But I'm still looking for an explanation!

Chickenhearted answered 26/3, 2011 at 22:15 Comment(0)
T
4

Tried visiting here ? SimpleComboBox Problem in GWT

Trisaccharide answered 27/3, 2011 at 2:55 Comment(2)
Thanks for the answer. The linked forum thread did help to solve the problem (insert combo.setTriggerAction(TriggerAction.ALL);), but it didn't help me to understand, why I need to do this, or why the old behavior was wrong. Why would setSimpleValue remove the other values? It doesn't make any sense to me.Chickenhearted
It doesn't make sense, but that's what it does. I've experienced this problem as well.Fir
H
8

I guess this is caused by the filtering feature of the combobox. This works by checking the string input and tries to match it with the values in its store - then only displays those items it thinks are relevant to the string input.

Since you made "two" the default value it thinks someone wrote "two" in there and tries to help you by showing only those values that you could think of while typing "two".

Hibben answered 26/5, 2011 at 8:22 Comment(0)
T
4

Tried visiting here ? SimpleComboBox Problem in GWT

Trisaccharide answered 27/3, 2011 at 2:55 Comment(2)
Thanks for the answer. The linked forum thread did help to solve the problem (insert combo.setTriggerAction(TriggerAction.ALL);), but it didn't help me to understand, why I need to do this, or why the old behavior was wrong. Why would setSimpleValue remove the other values? It doesn't make any sense to me.Chickenhearted
It doesn't make sense, but that's what it does. I've experienced this problem as well.Fir
F
0

You probably need to set combo.setForceSelection(true);

Fir answered 29/3, 2011 at 13:15 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.