GXT 3 问题:
有谁知道为什么当我选择网格上的任何行时不会触发这两个处理程序?SelectionModel 为 GridSelectionModel,设置为单选。
是否需要进一步申报?就这么简单,不是吗。我为 GXT 2.2 添加事件侦听器没有问题,但 GXT 3 有一些变化。这些事件用于检测行选择,不是吗?
SelectionChangedHandler<Summary> gridSelectionChangedHandler =
new SelectionChangedHandler<Summary>() {
public void onSelectionChanged(
SelectionChangedEvent<Summary> event) {
Summary rec = event.getSelection().get(0);
Window.alert("Row = "+ rec.getId());
}
};
SelectionHandler<Summary> gridSelectionHandler =
new SelectionHandler<Summary>() {
public void onSelection(SelectionEvent<Summary> event) {
Summary rec = event.getSelectedItem();
Window.alert("Row = "+ rec.getId());
}
};
public SummaryViewImpl() {
uiBinder.createAndBindUi(this);
this.grid.addSelectionChangedHandler(gridSelectionChangedHandler);
this.grid.addSelectionHandler(gridSelectionHandler);
}
但是,我对 RowClickEvent 没有任何问题,因为以下内容正在触发:
@UiHandler({ "grid" })
void onRowClick(RowClickEvent event){
int row = event.getRowIndex();
Window.alert("Row = "+ row);
}
grid 是 SummaryGrid 的一个实例:
public class SummaryGrid
extends Grid<Summary>{
{
this.sm = new GridSelectionModel<Summary>();
this.sm.setSelectionMode(SelectionMode.SINGLE);
}
blah ... blah ...
public HandlerRegistration addSelectionChangedHandler(SelectionChangedHandler<Summary> handler){
return this.getSelectionModel().addSelectionChangedHandler(handler);
}
public HandlerRegistration addSelectionHandler(SelectionHandler<Summary> handler){
return this.getSelectionModel().addSelectionHandler(handler);
}
blah ... blah ...
}