Birke
(Birke Heeren)
August 9, 2017, 9:05am
1
Hi,
on https://vaadin.com/docs/-/part/framework/components/components-grid.html
you write:
Grid grid = new Grid<>(Person.class);
grid.getColumn(“birthDate”).setWidth(“100px”);
grid.setItems(people);
The grid.getColumn(“birthDate”)
does not work. I get a NullPointerException.
ollit.1
(Olli Tietäväinen)
August 9, 2017, 10:01am
2
Hi,
does your Person bean have a birthDate property?
-Olli
Birke
(Birke Heeren)
August 9, 2017, 11:30am
4
Column<Person, String> nameColumn = grid.addColumn(Person::getName)
.setCaption(“Name”);
System.out.println(nameColumn.getId());
This returns null
Birke
(Birke Heeren)
August 9, 2017, 12:57pm
5
How to add a column otherwise?
ollit.1
(Olli Tietäväinen)
August 9, 2017, 12:47pm
6
Hi,
I think that’s because you’re adding the column with a method reference. You don’t get an id for the column in that case, only an internal generated id.
-Olli
ollit.1
(Olli Tietäväinen)
August 9, 2017, 1:03pm
7
There are quite a few overloads of that method:
https://vaadin.com/api/8.1.1/com/vaadin/ui/Grid.html#addColumn-java.lang.String-
but I’m not sure where you actually need that id value there.
-Olli
Birke
(Birke Heeren)
August 9, 2017, 1:21pm
8
I want to use:
HeaderRow groupingHeader = grid.prependHeaderRow();
HeaderCell personCell = groupingHeader.join(groupingHeader.getCell(“name”),
groupingHeader.getCell(“birthDate”));
personCell.setText(“Person”);
But I can not make it work.
ollit.1
(Olli Tietäväinen)
August 10, 2017, 6:36am
9
Have you tried using the version of groupingHeader that takes Grid.Column instead?
-Olli
Birke
(Birke Heeren)
August 10, 2017, 7:50am
10
It works! Thank you very much!