Adding Column to a Grid for a property in the referenced object.

From the documentation,

For example, if Person has a reference to an Address object, which has a property postalCode, you can add a column for the postal code with:


The column’s key will be "address.postalCode" and it’s header will be "Postal Code".

But when I try similar process, I am getting the below error. What did I miss ?

Caused by: java.lang.UnsupportedOperationException: This method can't be used for a Grid that isn't constructed from a bean type

	at com.vaadin.flow.component.grid.Grid.addColumn(

Like the error message says, if you’re not using the Grid<>(YourBean.class) constructor (which scans your bean class for properties and automatically adds columns), you can’t use the addColumn overload that takes a String input parameter.

You can either switch to that method (if you’re ok with the Columns coming from your bean class’s properties) or use another overload of the addColumn method. For example, one with a Lambda expression, like grid.addColumn(address -> address.getPostalCode());


Thanks, that worked.

I think the documentation should be little bit more clear.

Sure. Can you give a link to the docs page where that part you quoted is?


Here is the link.

Thanks. There’s a clarifying pull request to the documentation here: - note that it’s a public repository, so changes can be suggested there too.