i am trying to show a list of String-Arrays in a grid. For example having the two arrays [a,b,c]
and [1,2,3]
in a list as data it should result in two rows and 3 columns
a|b|c
1|2|3
Is this possible with vaadin-grid? I don’t know how to implement the value provider or renderer. Somehow i need to reference my values by column index.
private final Grid<List<String>> listGrid = new Grid<>();
listGrid.addColumn(list -> list.get(0)).setHeader("First item of list");
listGrid.addColumn(list -> list.get(1)).setHeader("Second item of list");
Thanks for your answer and sorry, i forgot an important information. The problem is that i don’t know the number of columns and have to do this in a loop.
private final Grid<List<String>> listGrid = new Grid<>();
for (int i = 0; i < numberOfColumns; i++) {
listGrid.addColumn(list -> list.get(i)).setHeader("list item " + i);
}
This does not compile, cause i is not final and can not used in the lambda expression.
Thanks for your answer. I am a little bit ashamed, that i did not saw this solution myself. I am using eclipse as ide and don’t get any hints for this problem.