I need a “custom selection model” for the GWT CellTable. One of the columns in CellTable is the Checkbox column.
Basic requirements (both work in the solution below):
- Clicking on a line (not on the check box) selects this line and does not select all the other lines.
- Selecting the checkbox should select / deselect only this line.
Below is the code I'm using, but it is very slow. Any recommendations would be appreciated.
final SelectionModel<T> selectionModel = new MultiSelectionModel<T>();
dataTable.setSelectionModel(selectionModel,
DefaultSelectionEventManager.createCustomManager(
new DefaultSelectionEventManager.CheckboxEventTranslator<T>() {
@Override
public SelectAction translateSelectionEvent(CellPreviewEvent<T> event) {
SelectAction action = super.translateSelectionEvent(event);
if (action.equals(SelectAction.IGNORE)) {
selectionModel.clear();
return SelectAction.TOGGLE;
}
return action;
}
}
)
);
Below is the code shot for the CheckColumn callback.
Column<T, Boolean> checkColumn = new Column<T, Boolean>(
new CheckboxCell(true, false))
{
@Override
public Boolean getValue(T t)
{
return selectionModel.isSelected(t);
}
};
AM01 source
share