GWT CellTable与复选框选择和行单击事件 [英] GWT CellTable with checkbox selection and on row click event
问题描述
如何在使用复选框选择模型单击某行时调用方法?
我正在设置复选框选择模型,如下所示:
table.setSelectionModel(selectionModel,
DefaultSelectionEventManager。< T> createCheckboxManager(0));
我找到了解决方案!而不是使用 createCheckboxManager()
,使用 createCustomManager()
传递参数 EventTranslator
扩展了
CheckboxEventTranslator
,并执行 translateSelectionEvent
方法的委托,只拦截忽略的事件超级( CheckboxEventTranslator
)。
源代码:
(
DefaultSelectionEventManager.CheckboxEventTranslator< T>(){
@Override
公共SelectAction translateSelectionEvent(CellPreviewEvent< T>事件){
SelectAction action = super.translateSelectionEvent(event);
if(action.equals(SelectAction.IGNORE)){
GWT.log(做你想要的东西!!!);
返回SelectAction.IGNORE;
}
返回操作;
}
}
)
);
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.setSelectionModel(selectionModel,
DefaultSelectionEventManager.<T> createCheckboxManager(0));
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;
}
}
)
);
这篇关于GWT CellTable与复选框选择和行单击事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!