microwth
microwth

Reputation: 1066

Vaadin one to many Grid binding and expanding child entity

There is the Customer entity which has a one to many relationship to entity Address,so there is a List<Address> getAddress in Customer.Entity Address has three columns,Street,City and Country.

So for instance to get the address details for one customer with two addresses you do

customer.getAddress.get(0).getStreet
customer.getAddress.get(0).getCity
customer.getAddress.get(0).getCountry

For the second address you do

customer.getAddress.get(1).getStreet
customer.getAddress.get(1).getCity
customer.getAddress.get(1).getCountry

Is there a way to display one row for the Customer details and display a sub-grid or (just dump the Address object's contents) that expands the Address entity and shows the two address rows with the 3 columns?

In essence show the parent and expand the child.I was looking at TreeGrid but it requires a single type of bean like TreeGrid and I don't know how Address would fill into the picture.

Does the basic Grid have a feature like that? I see that you can add different types of columns with addComponentColumn,but is that only for UI elements,like adding buttons etc ?

Upvotes: 0

Views: 426

Answers (1)

Leander A.
Leander A.

Reputation: 96

you could use a LitRenderer for that, but displaying this much data in a grid would extend the height of a row a lot.

With addComponentColumn you can add any Component you want, like a single Button, Image or a more complex Layout that you created.

Like Tatu Lund suggested you can use the ItemDetailsRenderer. There you can implement a LitRenderer or a ComponentRenderer. Then you can display all complex information about the customer.

Upvotes: 1

Related Questions