nick
nick

Reputation: 249

create and assign a component to a vaadin grid column

Inside a for loop I use:

 Grid.Column<Record> nameColumn =  new Label(value);
           
 grid.addComponentColumn(item -> nameColumn).setHeader(strSelectColumnNames[c]);
           
          TextField firstNameField = new TextField();
           nameColumn.setEditorComponent(firstNameField);

but the first line is not correct. I need nameColumn in order to set the editor component. How can I change the new Label(value)?

Thank you

Upvotes: 0

Views: 1340

Answers (1)

Anna Koskinen
Anna Koskinen

Reputation: 1370

You should return a different component instance for each row.

grid.addComponentColumn(item -> new Label(value));

Usage example: https://vaadin.com/components/vaadin-grid/java-examples/using-components

Upvotes: 4

Related Questions