GWT CellTable with checkbox selection and on row click event

橙三吉。 提交于 2019-12-03 03:27:44

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<T>() {
            @Override
            public SelectAction translateSelectionEvent(CellPreviewEvent<T> event) {
                SelectAction action = super.translateSelectionEvent(event);
                if (action.equals(SelectAction.IGNORE)) {
                    GWT.log("DO WHAT YOU WANT!!!");
                    return SelectAction.IGNORE;
                }
                return action;
            }
        }
    )
);

Create a function that you call,

table.setSelectionModel(selectionModel, ClassName.myMethod(0));

static <T> DefaultSelectionEventManager<T> myMethod(int column) {
   //call whatever functions you want
   return DefaultSelectionEventManager.<T> createCheckboxManager(column);
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!