1
我发现如果您有GWT CellTable
并添加一列包含CheckboxCell
,则通过SingleSelectionModel
的选择不再有效。这种单元格类型会阻碍行选择。 下面的代码示例演示了2.5.0.rc1中的这种行为。GWT CheckboxCell阻碍CellTable中的选择
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
还是有错误?
你想做什么?应该点击一行选择它?还检查复选框?应该检查复选框选择行?当你添加'CheckboxCell'时究竟发生了什么? – 2013-02-15 10:08:37
只要没有选择其他行,我试图保持选中的行(以蓝色突出显示)(请参阅我的[上一篇文章](http://stackoverflow.com/questions/14851651/gwt-celltable-keep-focus) -on选择的行))。用户点击哪个单元并不重要。选择模型实际上做我想做的事情。现在的问题是,如果我添加一个CheckboxCell,它就会关闭selectionModel不再工作(如果你将一个SelectionChangeHandler添加到模型中,它不会再被触发)。 – Adrian 2013-02-15 10:36:06
如果复选框不控制或取决于选择,为什么你使用'new CheckBox(true,true)'呢? (可能无法解决你的问题,只是传递中的一句话) – 2013-02-15 11:05:12