我有一个单元格表,其中最后一列是一个复选框。我想添加一个 Check-All-Box 作为页脚,单击该页脚时会选择每一行的每个复选框。不知何故,它在这里不起作用是我到目前为止得到的:
Column<Object, Boolean> select = new Column<Object, Boolean>(new CheckboxCell()) {
@Override
public Boolean getValue(Object object) {
return msm.isSelected(object);
}
};
select.setFieldUpdater(new FieldUpdater<Object, Boolean>() {
public void update(int index, Object object, Boolean value) {
msm.setSelected(object, value);
}
});
final Header selectAllHeader = new Header(new CheckboxCell()) {
@Override
public Boolean getValue(){
return msm.getSelectedSet().size() == getRowCount();
}
};
selectAllHeader.setUpdater(new ValueUpdater<Boolean>() {
@Override
public void update(Boolean value) {
for (Object o : getVisibleItems) {
msm.setSelected(o, value);
}
}
});
//works
addColumn(select, selectAllHeader);
//does not work
//addColumn(select, HEADER, selectAllHeader);