In my project i have CellTable with CheckBoxCell column. This is regular column to represent (change) values and doesn't use for row selection (for selection i use SingleSelectionModel). In Chrome everything works fine, on first click I get checkbox state changed and row selected. In FireFox when I try to click on check box in CheckBoxCell column GWT selects row and after second click on checkbox it change checkbox state. But I need the same behavior as in Chrome (change checkbox state on first click).
Here is how i create column:
private <C> Column<T, C> addColumn(CellTable<T> itemListTable, Cell<C> cell, String headerText, int columnWidthPct, final IValueGetter<C, T> getter, @Nullable FieldUpdater<T, C> fieldUpdater) {
Column<T, C> column = new Column<T, C>(cell) {
@Override
public C getValue(T object) {
return getter.getValue(object);
}
};
column.setFieldUpdater(fieldUpdater);
column.setSortable(false);
itemListTable.addColumn(column, headerText);
itemListTable.setColumnWidth(column, columnWidthPct, PCT);
return column;
}
private void generateExistingSettingsTable() {
addColumn(existingSettingsTable, new ParameterizedCheckboxCell<T>(), IS_PUBLIC_HEADER, 10, new IValueGetter<Boolean, T>() {
@Override
public Boolean getValue(T setting) {
return setting.isPublic();
}
},
new FieldUpdater<T, Boolean>() {
@Override
public void update(int index, T object, Boolean value) {
object.setPublic(value);
updatePublicState(object);
}
}
);
}
My ParameterizedCheckboxCell extends CheckboxCell and overrides only render method (to enable\disable checkbox input).
I already tried everything suggested here here:
- stopPropagation doesn't works for me
- Add column to DefaultSelectionEventManager black list, is not an option (very large area left unclickable around checkbox)
As i found out today, the same thing happen with Chrome (version 45.0.2454.101). I investigate this more and find out the following. GWT
CheckboxCell
by default consume only two browser events:keydown
andchange
. In old Chrome version when you clicked on checkboxchange
event fired and everything works fine. In FireFox and in the new Chrome version there is nochange
event after click (i cannot figure out why, explanations are welcome), so i decide to create my own checkbox class that extendsAbstractEditableCell<Boolean, Boolean>
and replace consumedchange
toclick
event. Here is what i got:I skipped
dependsOnSelection
andhandlesSelection
because i dont use this for selection column.