我发现如果您有一个 GWTCellTable
并添加一个包含 a 的列CheckboxCell
,则通过 a 进行的选择SingleSelectionModel
不再起作用。这种单元格类型确实会阻碍行选择。遵循在 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);
您可以组合多个单元格并将它们添加到表格中(例如LinkActionCell
等)。只要没有CheckboxCell
,蓝色的选择与SingleSelectionModel
作品一样有魅力。有没有人看到我做错了什么CheckboxCell
或者有错误?