get object from Grid (Vaadin 8)

Hello all,

I’m just starting to use the Vaadin framework and i really like it.
At this moment im struggling for over a day on this issue, and i can’t seem to find a way to do this.
I have read all the documentation about the Grid, but still i dont’t know how to do this…
My code:

List vals = controller.findAll(searchField.getValue());grid.setItems(vals); grid.setColumns(“valNr”, “client”, “reference”, “product”, “weight”, “plannedDate”, “readyDate”, “status”, “subStatus”);

grid.getColumn(“valNr”).setWidth(100).setCaption(“VAL”); grid.getColumn(“client”).setWidth(130).setCaption(“Klant”); grid.getColumn(“reference”).setWidth(150).setCaption(“Referentie”); grid.getColumn(“product”).setWidth(200).setCaption(“Product”); grid.getColumn(“weight”).setWidth(130).setCaption(“Input gewicht”); grid.getColumn(“plannedDate”).setWidth(150).setCaption(“Datum planned”); grid.getColumn(“readyDate”).setWidth(150).setCaption(“Datum gereed”); grid.getColumn(“status”).setWidth(150).setCaption(“Status”); grid.getColumn(“subStatus”).setWidth(150).setCaption(“Sub status”);

The above is working fine, my Grid is filled with all the correct data.
Now i want to expand the selected row with some extra data. (Maybe with details Generator?)
When i add this ClickListener, i can get the whole selected row in a String.

grid.addItemClickListener(event →“” + event.getItem()));

But i really want to get the selected row as an object so i can get and set the needed data in an expanded view.
Can you let me know about what is the correct way to do this? Really appreciate some help.


If you want to show details of the item, it would be something like,

grid.addItemClickListener(event → grid.setDetailsVisible(event.getItem(),true));

But first you would need to create new details generatorand set it with grid.setDetailsGenerator(…);

Hi Tatu,

Thanks for you reply, figured out now how to fix my issue!