GXT 3問題:GXT 3:GridSelectionModel SelectionEvent/SelectionChangedEvent不點火
有沒有人有,爲什麼當我選擇在網格中的任何行這兩種處理器都不會觸發任何想法? 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);
}
電網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 ...
}
getSelectionModel()返回this.sm.正如你所看到的,我正在做this.sm.setSelectionMode(SelectionMode.SINGLE)。閱讀我在這裏提供的用於擴展類的代碼。 – 2013-03-20 02:05:51