GWT CellTable Custom Model

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)
            {
                // Get the value from the selection model.
                return selectionModel.isSelected(t);
            }
        };
+3
source share
2 answers

I installed KeyProvider for CellTable and now it is not slow. :)

ProvidesKey<T> keyProvider = new ProvidesKey<T>() {
    public Object getKey(T t) {
        return tip == null? null : tip.getId();
    }
};
dataTable = new CellTable<T>(PAGE_SIZE, keyProvider);
+3
source

You can just reset your checkbox

int checkboxColumn = 0;
DefaultSelectionEventManager.createCustomManager(new DefaultSelectionEventManager
                                      .WhitelistEventTranslator(checkboxColumn));
0
source

All Articles