GWT CheckboxCell prevents selection in CellTable

I found that if you have a GWT CellTable

and add a containing column CheckboxCell

, selection with SingleSelectionModel

no longer works. This type of cell prevents row selection. Following the sample code that demonstrates this behavior in 2.5.0.rc1.

final CellTable<LicenseDto> licenseTable = new CellTable<LicenseDto>();
final SingleSelectionModel<LicenseDto> selectionModel = new SingleSelectionModel<LicenseDto>();
licenseTable.setSelectionModel(selectionModel);


//--- If I add this column, the selection does work.
Column<LicenseDto, String> workingColumn = new Column<LicenseDto, String>(new TextCell()) {

    @Override
    public String getValue(LicenseDto object) {
        return "Works";
    }
};
workingColumn.setFieldUpdater(new FieldUpdater<LicenseDto, String>() {

    @Override
    public void update(int index, LicenseDto object, String value) {
        ;
    }
});
licenseTable.addColumn(workingColumn);


//--- If I add this column, the selection does NOT work anymore.
Column<LicenseDto, Boolean> notWorkingColumn = new Column<LicenseDto, Boolean>(new CheckboxCell(true, true)) {

    @Override
    public Boolean getValue(LicenseDto object) {
        return object.getEnabled();
    }
};
notWorkingColumn.setFieldUpdater(new FieldUpdater<LicenseDto, Boolean>() {

    @Override
    public void update(int index, LicenseDto object, Boolean value) {
        presenter.enableLicense(object, value);
    }
});
licenseTable.addColumn(notWorkingColumn);

initWidget(licenseTable);

      

You can concatenate multiple cells and add them to the table (eg, LinkActionCell

etc.). Not yet CheckboxCell

, the blue choice SingleSelectionModel

works like a charm. Does anyone see what I am doing wrong with this CheckboxCell

or is there a bug?

+1


source to share


1 answer


Thank you Thomas! The problem was that I installed handlesSelection = true

, even thought I was not handling anything. Setting this parameter to false solves the problem. By the way, I add fieldUpdater

to the column to handle checking or unchecking a checkbox:

Column<LicenceDto, Boolean> enableLicenseColumn = new Column<LicenceDto, Boolean>(new CheckboxCell(false, false)) {

    @Override
    public Boolean getValue(LicenceDto object) {
        return object.getEnabled();
    }
};
enableLicenseColumn.setFieldUpdater(new FieldUpdater<LicenceDto, Boolean>() {

    @Override
    public void update(int index, LicenceDto object, Boolean value) {
        presenter.enableLicense(object, value);
    }
});

      



The answer to the question.

+3


source







All Articles