Question

i have a CellTable in my GWT Projekt with a CheckBox in each row. Somehow i need to iterate over all rows in the cellTable and need to check if the CheckBox of each row is selected or not.

I dont know how to do that and i cant find anything that shows how.

private Column<Article, Boolean> showPinColumn = new Column<Article, Boolean>(new CheckboxCell()) {
    public Boolean getValue(Article object) {
        return false;
    }
};
Was it helpful?

Solution

Step 1 - You should fix your showPinColumn code and use FieldUpdater to actually update the object.

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);
    }
});

Step 2- You should only iterate over each of the items in the "list" that you set into the celltable and check for the boolean property in Article.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top