具有CheckBoxes的GWT CellTable获得所有选中的Box

use*_*812 3 gwt celltable gwt-celltable

我的GWT Projekt中有一个CellTable,每行都有一个CheckBox.不知何故,我需要迭代cellTable中的所有行,并需要检查是否选中了每行的CheckBox.

我不知道该怎么做,我无法找到任何显示如何.

private Column<Article, Boolean> showPinColumn = new Column<Article, Boolean>(new CheckboxCell()) {
    public Boolean getValue(Article object) {
        return false;
    }
};
Run Code Online (Sandbox Code Playgroud)

app*_*tup 5

第1步 - 您应修复showPinColumn代码并使用FieldUpdater实际更新对象.

final CheckboxCell cbCell = new CheckboxCell();
Column<Article, Boolean> cbColumn = new Column<Article, Boolean>(cbCell) {
    @Override
    public Boolean getValue(Article object) {
        System.out.println("method getValue() - " + object.id + " - " + object.checked);
        return object.checked;
    }
};

cbColumn.setFieldUpdater(new FieldUpdater<Fieldupdater.Article, Boolean>() {
    @Override
    public void update(int index, Article object, Boolean value) {
        System.out.println("method update() - " + object.id + " - " + value);
    }
});
Run Code Online (Sandbox Code Playgroud)

第2步 - 您应该只迭代您在celltable中设置的"list"中的每个项目,并检查Article中的boolean属性.