--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To post to this group, send email to google-we...@googlegroups.com.
To unsubscribe from this group, send email to google-web-tool...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
Column<Message, Boolean> select = new Column<Message, Boolean>(new CheckboxCell(true)) {
@Override
public Boolean getValue(Message object)
{
return selectionModel.isSelected(object);
}
};
select.setFieldUpdater(new FieldUpdater<Message, Boolean>() {
public void update(int index, Message object, Boolean value)
{
// Called when the user clicks on a checkbox.
selectionModel.setSelected(object, value);
}
});
Header<Boolean> selectAllHeader = new Header<Boolean>(new CheckboxCell()) {
@Override
public Boolean getValue()
{
return selectionModel.getSelectedSet().size() == table.getRowCount();
}
};
selectAllHeader.setUpdater(new ValueUpdater<Boolean>() {
@Override
public void update(Boolean value)
{
List<Message> displayedItems = table.getDisplayedItems();
for (Message msg : displayedItems)
{
selectionModel.setSelected(msg, value);
}
}
});
table.addColumn(select, selectAllHeader);
Thanks for showing how to add an checkbox in the celltable header.
I have another question in this regard.
I am showing this celltable data with checkbox header as above
as first column and
other columns as Name, Address, etc.
Also I am using SimplePager to show the data in celltable
in paginated format with pagesize 5.
Question:
The first 5 records are shown in first page and
when the uses clicks the
checkbox header cell all the first 5 records in the celltable are selected
alongwith the checkbox header cell itself.
On paging to next page by clicking the next page image(or icon) on the
SimplePager, the next 5 records from the celltable are shown
but the checkbox header cell remains selected (true)
as I had clicked it in the first page.
I need the checkbox header as unchecked again (false)
when the user clicks on the
next page and new records are shown.
SimplePager does on raise any event
on clickcing the next page image(or icon).
Please Help
Thanks and Regards,
atul gaikwad
atul- I used the MyHeader class from
http://snipt.net/araujo921/checkbox-in-gwt-celltable-header/ and added one more
method to it:
public void setValue(int column, boolean value) {
this.value = value;
changeValue.changedValue(column, value);
}
for the celltable, add loading state change handler; this way you don't have to
worry about "what happens on sort (if you are doing server-side sorting)",
pagination etc.
table.addLoadingStateChangeHandler(new LoadingStateChangeEvent.Handler() {
@Override
public void onLoadingStateChanged(LoadingStateChangeEvent event) {
if (event.getLoadingState().equals(LoadingState.LOADING)) {
checkBoxHeader.setValue(false);
}
});
taha