PDA

View Full Version : Editable ComboBox in CellEditor



cwsunderland
15 Dec 2011, 1:23 PM
I'm having trouble getting a SimpleComboBox in a CellEditor to retrieve a typed value. I want the combo box to be able to allow user input as well as the user being able to drop it down an select a pre-defined value. Currently, if the user enters there own value it reverts back to the last selected value from the dropdown (if there was one).

I'm just using the standard code from the editor grid example:



final SimpleComboBox<String> comboBox = new SimpleComboBox<String>();
comboBox.setTriggerAction(TriggerAction.ALL);
comboBox.add(values);

CellEditor editor = new CellEditor(comboBox) {
@Override
public Object preProcessValue(Object value) {
if (value == null) {
return value;
}
return comboBox.findModel(value.toString());
}

@Override
public Object postProcessValue(Object value) {
if (value == null) {
return value;
}
return ((ModelData) value).get("value"); //$NON-NLS-1$
}
};