in the column Price type 7 and press Enter - ok
in the column Price delete the number 7 and press enter - ok (value == null)
in the column Price type 5 and press Enter - return NullPointer
the problem appears when you type on value and need return null..
code example
Code:
public void onModuleLoad() {
List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
ColumnConfig column = new ColumnConfig();
column.setId("name");
column.setHeader("Common Name");
column.setWidth(220);
TextField<String> text = new TextField<String>();
text.setAllowBlank(false);
text.setAutoValidate(true);
column.setEditor(new CellEditor(text));
configs.add(column);
final SimpleComboBox<String> combo = new SimpleComboBox<String>();
combo.setTriggerAction(TriggerAction.ALL);
combo.add("Shade");
combo.add("Mostly Shady");
combo.add("Sun or Shade");
combo.add("Mostly Sunny");
combo.add("Sunny");
column = new ColumnConfig();
column.setId("light");
column.setHeader("Light");
column.setWidth(130);
configs.add(column);
CellEditor editor = new CellEditor(new NumberField()) {
@Override
public Object postProcessValue(Object value) {
if (value != null) {
Number number = (Number) value;
if (number.intValue() == 5) {
return null;
} else {
return super.postProcessValue(value);
}
} else {
return null;
}
}
};
column = new ColumnConfig();
column.setId("price");
column.setHeader("Price");
column.setAlignment(HorizontalAlignment.RIGHT);
column.setWidth(70);
column.setNumberFormat(NumberFormat.getCurrencyFormat());
column.setEditor(editor);
configs.add(column);
DateField dateField = new DateField();
dateField.getPropertyEditor().setFormat(DateTimeFormat.getFormat("MM/dd/y"));
column = new ColumnConfig();
column.setId("available");
column.setHeader("Available");
column.setWidth(95);
column.setEditor(new CellEditor(dateField));
column.setDateTimeFormat(DateTimeFormat.getMediumDateFormat());
configs.add(column);
CheckColumnConfig checkColumn = new CheckColumnConfig("indoor", "Indoor?", 55);
configs.add(checkColumn);
final ListStore<Plant> store = new ListStore<Plant>();
store.add(TestData.getPlants());
ColumnModel cm = new ColumnModel(configs);
final EditorGrid<Plant> grid = new EditorGrid<Plant>(store, cm);
grid.setAutoExpandColumn("name");
grid.setBorders(true);
grid.addPlugin(checkColumn);
ContentPanel panel = new ContentPanel();
panel.add(grid);
RootPanel.get().add(panel);
}