GWT CellTable with checkbox selection and on row click event

前端 未结 2 1194
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 21:41

How to call a method when some row is clicked using the checkbox selection model?

I\'m setting the checkbox selection model like this:

table.setSelection         


        
2条回答
  •  你的背包
    2021-02-05 22:18

    I found a solution! Instead of using createCheckboxManager(), use createCustomManager() passing by argument an EventTranslator that extends the CheckboxEventTranslator and do a delegation of the translateSelectionEvent method, intercepting only the events ignored by the super (CheckboxEventTranslator).

    The source code:

    table.setSelectionModel(selectionModel, 
        DefaultSelectionEventManager.createCustomManager(
            new DefaultSelectionEventManager.CheckboxEventTranslator() {
                @Override
                public SelectAction translateSelectionEvent(CellPreviewEvent event) {
                    SelectAction action = super.translateSelectionEvent(event);
                    if (action.equals(SelectAction.IGNORE)) {
                        GWT.log("DO WHAT YOU WANT!!!");
                        return SelectAction.IGNORE;
                    }
                    return action;
                }
            }
        )
    );
    

提交回复
热议问题