tpow
tpow

Reputation: 7884

Can't get Row Click Handler for GWT CellTable

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)

Upvotes: 2

Views: 3200

Answers (3)

iavci
iavci

Reputation: 209

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");
}               
}       
});

Upvotes: 0

Thomas Broyer
Thomas Broyer

Reputation: 64541

Use a NoSelectionModel and listen to SelectionChange events.

Upvotes: 3

Javier Ferrero
Javier Ferrero

Reputation: 8811

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

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

Upvotes: 4

Related Questions