PDA

View Full Version : OnChange / AfterEdit event for EditorGrid with checkbox column



egotec
26 Jul 2010, 5:41 AM
Hello.

I have a EditorGrid with a Checkbox column:

CellEditor checkBoxEditor = new CellEditor(new CheckBox());
[...]
gridEmployees = new EditorGrid<ModelData>(new ListStore<ModelData>(), new ColumnModel(configs_3));

Now, I'd like to be notified when a row was edited.

gridEmployees.addListener(Events.AfterEdit, changeListener);

But the event isn't coming when I check the checkbox. When I use a SimpleComboBox instead of the CheckBox, the event is coming when I change the selection. But I need the checkbox...

Thanks for your help,
Jonas.

sven
26 Jul 2010, 5:43 AM
Please post more code about "configs_3"

egotec
26 Jul 2010, 5:53 AM
List<ColumnConfig> configs_3 = new ArrayList<ColumnConfig>();

ColumnConfig lastName = new ColumnConfig("lastName", CONSTANTS.nlsLastName(), 120);
configs_3.add(lastName);

ColumnConfig givenName = new ColumnConfig("givenName", CONSTANTS.nlsFirstName(), 120);
configs_3.add(givenName);

CheckColumnConfig checkSupervisor = new CheckColumnConfig("isSupervisor", CONSTANTS.nlsDepartmentManager(), 100);
CellEditor checkBoxEditor = new CellEditor(new CheckBox());
checkSupervisor.setEditor(checkBoxEditor);
configs_3.add(checkSupervisor);

gridEmployees = new EditorGrid<ModelData>(new ListStore<ModelData>(), new ColumnModel(configs_3));
gridEmployees.setAutoWidth(true);
gridEmployees.setAutoHeight(true);
gridEmployees.setBorders(true);
gridEmployees.addPlugin(checkSupervisor);

sven
26 Jul 2010, 5:54 AM
When using a CheckColumnConfig you are not using any functionality of the editorgrid. Also you dont need to to set any celleditor than. Change it to a normal ColumnConfig and it will work.

egotec
26 Jul 2010, 6:17 AM
Ok thanks,
but then the grid looks ugly because in the cell is the text "true" or "false" and the checkbox will only appear when I click on a cell.

sven
26 Jul 2010, 6:23 AM
So add a CellClick listener to the grid. and check for the columnindex. You can use a normal grid in this case together with the checkcolumnconfig.

sven
26 Jul 2010, 6:24 AM
but then the grid looks ugly because in the cell is the text "true" or "false"

You can change this with a custom GridCellRenderer