PDA

View Full Version : Grid with checkbox. How to catch OnChange event.



Mebel
27 Apr 2011, 4:43 AM
Hello,

when i use this code to add a checkbox in my Grid how it possible to get the onChange event from the checkbox ? I have tried to add listener on the celleditor, checkbox and on the grid. Also i have override completeEdit but i cant catch the event.



CheckColumnConfig checkColumn = new CheckColumnConfig("indoor", "Indoor?", 55);
CellEditor checkBoxEditor = new CellEditor(new CheckBox());
checkColumn.setEditor(checkBoxEditor);
configs.add(checkColumn);


regards
me

gaspo100
27 Apr 2011, 8:07 PM
I use Events.CellMouseUp



List<ColumnConfig> configs = new ArrayList<ColumnConfig>();
configs.add(new ColumnConfig("Column0", "Text Col 0", 100));
configs.add(new ColumnConfig("Column1", "Text Col 1", 100);

CheckColumnConfig checkColumn = new CheckColumnConfig("Column2", "Check Col 2", 100);
CellEditor checkBoxEditor = new CellEditor(new CheckBox());
checkColumn.setEditor(checkBoxEditor);
configs.add(checkColumn);

ListStore store = new ListStore<MyModel>();

Grid grid = new Grid<MyModel>(store, new ColumnModel(configs));
grid.addPlugin(checkColumn);
grid.addListener(Events.CellMouseUp, new Listener<GridEvent<MyModel>>() {
@Override
public void handleEvent(GridEvent<MyModel> be) {
if (be.getColIndex() == 2) {
// use be.model to read status of the check box column
}
}
});