2

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)

Community
  • 1
  • 1
tpow
  • 7,600
  • 11
  • 59
  • 84

3 Answers3

4

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

"click".equals(event.getNativeEvent().getType());
Javier Ferrero
  • 8,741
  • 8
  • 45
  • 50
3

Use a NoSelectionModel and listen to SelectionChange events.

Thomas Broyer
  • 64,353
  • 7
  • 91
  • 164
0

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");
}               
}       
});
Bo Persson
  • 90,663
  • 31
  • 146
  • 203
iavci
  • 189
  • 1
  • 4