Hi,
I have a cell table with a column that contains a checkbox. Now I would
like to add a 'select all box' that when selected all other checkboxes in
the cell table are selected. I tried to use a MultiselectionModel for that.
When I add the select all check box as a footer it does not work at all
only when I add it as the header widget it 'kinda' works. Here is how I use
it:
MultiselectionModel<Object> msm = new MultiSelectionModel<Object>();
table.setSelectionModel(msm, DefaultSelectionEventManager.<Object>
createCheckboxManager());
Header<Boolean> selectAllHeader = new Header<Boolean>(new CheckboxCell()) {
@Override
public Boolean getValue() {
return msm.getSelectedSet().size() == table.getRowCount();
}
};
selectAllHeader.setUpdater(new ValueUpdater<Boolean>() {
@Override
public void update(Boolean value) {
for (Object msg : table.getVisibleItems()) {
msm.setSelected(msg, value);
}
}
});
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);
}
});
Header<String> colHeader = new Header<String>(new TextCell()) {
@Override
public String getValue() {
return "HEADER";
}
};
//when adding like this does select all does not work
table.addColumn(select, colHeader, selectAllHeader);
//when adding the select all check box as header it 'kinda' works
table.addColumn(select, selectAllHeader);
With kinda works I mean the following:
- Click on Check-all box -> everything is selected but check-all box is not
selected (NOT OK)
- Click on check-all box again -> everything still selected and now also
check-all box selected (OK)
- Click on check-all box again -> nothing is selected but check-all box is
still selected (NOT OK)
- Click on check-all box again -> nothing is selected and now also
check-all box is not selected (OK)
Please can anyone help me??
--
You received this message because you are subscribed to the Google Groups
"Google Web Toolkit" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-web-toolkit/-/DNep2poTx30J.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-web-toolkit?hl=en.