I'm trying to add a selection listener to my GXT (Ext GWT) Grid, but I can't seem to get it to fire. I've tried many variations of this with no luck:
myGrid.addListener(Events.Select, new SelectionListener<ComponentEvent>() {
@Override
public void componentSelected(ComponentEvent ce) {
System.out.println("selected");
}
});
myGrid.getSelectionModel().addSelectionChangedListener(new SelectionChangedListener<ModelData>() {
@Override
public void selectionChanged(SelectionChangedEvent<ModelData> se) {
...
}
});
Try this code
To upgrade this answer to GXT v3
grid.getSelectionModel().addSelectionChangedHandler(
new SelectionChangedHandler<ModelData>(){
@Override
public void onSelectionChanged(SelectionChangedEvent<ModelData> event) {
}
});
Try:
myGrid.addListener(Events.Select, new Listener<GridEvent<ModelData>>() {
@Override public void handleEvent(GridEvent<ModelData> be) {
System.out.println("selected");
}
});
Replacing ModelData with your model type if necessary.
Seemed to have found a workaround for this:
myGrid.addListener(Events.OnClick, new Listener<ComponentEvent>() {
@Override
public void handleEvent(ComponentEvent ce) {
// Handle the grid event
}
});
Seems like you just have to be generic about it, then you can check and cast your ComponentEvent to a GridEvent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With