I am trying to capture the onclick event from a textcell. why does not this fire the click event –
TextCell tempCell = new TextCell() {
@Override
public void onBrowserEvent(Cell.Context context, Element parent, String value,
NativeEvent event, ValueUpdater<String> valueUpdater) {
if ("click".equals(event.getType())) {
Window.alert("Clicked me from cell");
}
}
};
Column<Contact, String> tempColumn = new Column<Contact, String>(tempCell) {
@Override
public String getValue(Contact object) {
return object.address;
}
};
table.addColumn(tempColumn, "Address");
This will not work because TextCell does not consume any events. You must sub-class AbstractSafeHtmlCell instead and tell it which events you want to consume by passing them into the constructor.
This will do: