I have a CellTable with a few rows for which I use MultiSelectionModel. The first column is a column of checkbox cells. When the user checks one of the checkboxes the row becomes selected (as per the example in the site) and when the user clicks a row a function "doActionOnRow()" is called.
My problem is that when the user checks a checkbox the "doActionOnRow()" is also called. How can I make the CheckboxCell consume the click event so it wont be triggered on the celltable as well ?
EDIT:
This is my code:
table.addCellPreviewHandler(new Handler<Patient>() {
@Override
public void onCellPreview(CellPreviewEvent<Patient> event) {
boolean isClick = "click".equals(event.getNativeEvent().getType());
if (isClick) {
doSomething();
}
}});
Column<Patient, Boolean> checkColumn = new Column<Patient, Boolean>(new CheckboxCell(true, false)) {
@Override
public Boolean getValue(Patient object) {
// Get the value from the selection model.
return sm.isSelected(object);
}
@Override
public void onBrowserEvent(Context context, Element elem, Patient patient, NativeEvent event) {
if ("click".equals(event.getType()))
event.stopPropagation();
super.onBrowserEvent(context, elem, patient, event);
}
};
table.addColumn(checkColumn, SafeHtmlUtils.fromSafeConstant("<br/>"));
Even when I add event.stopPropagation();
doSomething();
is called when I click the checkbox.
Any idea why ?