-1

I have a Grid backed by a BeanItemContainer. Is there a way to add columns to it? I was unable to find a way since it gave me many errors. I ended up manually adding rows to a grid instead. I tried adding generated properties or plain properties without luck.

public final class ExecutionGrid extends Grid {

    public ExecutionGrid(String caption) {
        super(caption);
    }

    public ExecutionGrid(String caption, List<Step> steps) {
        super(caption);
        setSteps(steps);
    }

    /**
     * Add steps to this grid.
     *
     * @param steps Steps to set. It deletes any previous ones stored.
     */
    public void setSteps(List<Step> steps) {
        //Clear grid
        removeAllColumns();
        setHeightByRows(steps.size());
        setHeightMode(HeightMode.ROW);
        Grid.Column textColumn = addColumn("text", byte[].class);
        textColumn.setHeaderCaption("Text");
        textColumn.setConverter(new ByteToStringConverter());
        Grid.Column expectedResultColumn = addColumn("expectedResult", byte[].class);
        expectedResultColumn.setHeaderCaption("Expected Result");
        expectedResultColumn.setConverter(new ByteToStringConverter());
        Grid.Column notesColumn = addColumn("notes", String.class);
        notesColumn.setHeaderCaption("Notes");
        Grid.Column resultColumn = addColumn("result", String.class);
        resultColumn.setHeaderCaption("Result");
        steps.forEach((s) -> {
            addRow(s.getText(), s.getExpectedResult(), s.getNotes(), "");
        });
    }
}

Wonder if I'm missing something.

javydreamercsw
  • 5,363
  • 13
  • 61
  • 106

1 Answers1

0

Please correct me if I am wrong but think there is no way by doing this within the Grid directly. It may having something to do with this reflection stuff that is used within the BeanItemContainer. However, you could create some kind of POJOs which has the needed attributes.

wirebug
  • 78
  • 1
  • 2
  • 7