GXT 3 question:
Does anyone have any idea why these two handlers are not triggered when I select any row on the grid? SelectionModel is GridSelectionModel, set to single selection.
Are there any further declaration to be done? It is as simple as this, isn't it. I had no problem adding event listeners for GXT 2.2, but there are some changes in GXT 3. These events are for detecting row selections, aren't they?
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);
}
However, I have no problem with RowClickEvent, as the following is firing:
@UiHandler({ "grid" })
void onRowClick(RowClickEvent event){
int row = event.getRowIndex();
Window.alert("Row = "+ row);
}
grid is an instance of 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 ...
}
try this grid.getSelectionModel().addSelectionChangedHandler
not sure if you need to set the selection mode first or not but my working code is like:
grid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);
grid.getSelectionModel().addSelectionChangedHandler(new SelectionChangedHandler<Summary>() {
...
}