2
votes

I'm trying to setup a Row-click handler for the GWT CellTable (GWT 2.1). The stackoverflow post here indicates that you should be able to get the type of handler using:

boolean isClick = "click".equals(event.getType()) 

But event.getType() doesn't return a string, so the evaluation isn't working. The CellPreviewEvent is working, but it fires lots of events (not just click), and I'm having a hard time figuring out how to only get the click events..

Has anyone found a solution to this? (Or can explain what I'm doing wrong in following the post)

3
I've also tried - "click".equals(event.getType().getClass().getName().toString();tpow

3 Answers

4
votes

You need to get the native event associated with the GwtEvent:

"click".equals(event.getNativeEvent().getType());
3
votes

Use a NoSelectionModel and listen to SelectionChange events.

0
votes

I'm using a check column with a celltable. You can handle selection change event like the sample below.

selectionModel.addSelectionChangeHandler(new Handler() {
@Override
public void onSelectionChange(SelectionChangeEvent event) {
    Contentshort objSelected = selectionModel.getSelectedObject();
if (selectionModel.isSelected(objSelected)) {
    Window.alert("selected");
} else {
    Window.alert("deselected");
}               
}       
});