On 9 nov, 16:40, Baloe <
nielsba...@gmail.com> wrote:
> Hi all,
>
> I'm trying to get a CheckboxCell working as a selector for the row,
> but it doesn't work. And there is no getValue() on the CheckboxCell as
> well, so any weird saving of added checkboxes is no alternative as
> well.
>
> The code is as follows:
> ...
> cellTable = new CellTable<DtoContactList>();
> cellTable.setSelectionModel(new
> MultiSelectionModel<DtoContactList>());
>
> flowPanel.add(cellTable);
>
> cellTable.addColumn(new Column<DtoContactList, Boolean>(
> new CheckboxCell(true)) {
> @Override
> public Boolean getValue(DtoContactList object) {
> return false;
> }
> }, new TextHeader("Select"));
> ...
> Because it says 'true' in the CheckboxCell, it should function as a
> selection controller, right?
No.
> Thanks for any hints!
See
http://gwt.google.com/samples/Showcase/Showcase.html#!CwCellTable
// Checkbox column. This table will uses a checkbox column for
selection.
// Alternatively, you can call cellTable.setSelectionEnabled(true)
to enable
// mouse selection.
Column<ContactInfo, Boolean> checkColumn = new Column<ContactInfo,
Boolean>(
new CheckboxCell(true)) {
@Override
public Boolean getValue(ContactInfo object) {
// Get the value from the selection model.
return selectionModel.isSelected(object);
}
};
checkColumn.setFieldUpdater(new FieldUpdater<ContactInfo,
Boolean>() {
public void update(int index, ContactInfo object, Boolean value)
{
// Called when the user clicks on a checkbox.
selectionModel.setSelected(object, value);
}
});
cellTable.addColumn(checkColumn,
SafeHtmlUtils.fromSafeConstant("<br>"));