I'm using gxt 2.0.3 in Java and I have created a SimpleComboBox which I then populate with 2 strings.
final SimpleComboBox<String> accessedComboBox = new SimpleComboBox<String>();
accessedComboBox.setTriggerAction(TriggerAction.ALL);
accessedComboBox.setEmptyText("Select a type");
accessedComboBox.add("Method 1");
accessedComboBox.add("Method 2");
I also have a listener attached to a different SimpleComboBox and depending on what is selected I need to either add or remove the value from the above accessedComboBox
if (typeComboBox.getSimpleValue() == "Type 1")
{
//Remove desktop app option
accessedComboBox.remove("Method 2");
}
else
{
if (accessedComboBox.??) { // <--- Check to see whether desktop app is an option
//if not then add it
accessedComboBox.add("Method 2");
}
}
I can't work out what function to use to check the see whether an option already exists in the SimpleComboBox. I have looked in this documentation but I've still had no luck.
Can anyone help?
Not sure if you got this yet. It's a little funky, but you can get the String values from the ListStore. Something like this:
for (SimpleComboValue<String> value : accessedComboBox.getStore().getModels()) {
if (!value.getValue().equals("Method 1")){
accessedComboBox.add("Method 1");
}
}