使用复选框选择模型单击某行时如何调用方法?
我正在设置这样的复选框选择模型:
table.setSelectionModel(selectionModel,
DefaultSelectionEventManager.<T> createCheckboxManager(0));
使用复选框选择模型单击某行时如何调用方法?
我正在设置这样的复选框选择模型:
table.setSelectionModel(selectionModel,
DefaultSelectionEventManager.<T> createCheckboxManager(0));
我找到了解决办法!不使用createCheckboxManager()
,而是使用createCustomManager()
传递参数 anEventTranslator
来扩展CheckboxEventTranslator
并执行translateSelectionEvent
方法的委托,仅拦截被 super ( CheckboxEventTranslator
) 忽略的事件。
源代码:
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;
}
}
)
);
创建一个你调用的函数,
table.setSelectionModel(selectionModel, ClassName.myMethod(0));
static <T> DefaultSelectionEventManager<T> myMethod(int column) {
//call whatever functions you want
return DefaultSelectionEventManager.<T> createCheckboxManager(column);
}