Anshaz
Anshaz

Reputation: 21

Adjusting Vaadin grid height

I am trying to add multiple Vaadin grids of different sizes inside a VerticalLayout container.

public class Overview extends VerticalLayout {

    Grid<DataTable1> grid1 = new Grid<>();

    Grid<DataTable12> grid2 = new Grid<>();

    Grid<DataTable13> grid3 = new Grid<>();
}

So far, each grid is taking up an equal amount of vertical space, as shown in the image below.

grids taking equal vertical space

However, I would like to show the grid as shown in the image below where the height gets dynamically adjusted as per the number of rows and cloumns:

desired grids

Is there any way I can adjust the individual grid height?

So far I have found a way to adjust the row height not the height of the whole grid itself.

Thank you!

Upvotes: 0

Views: 437

Answers (2)

Rolf
Rolf

Reputation: 2418

Sounds like you might be looking to achieve dynamic height based on the number of rows, which can be done using setAllRowsVisible(true): https://vaadin.com/docs/latest/components/grid/#dynamic-height

Upvotes: 3

Simon Martinelli
Simon Martinelli

Reputation: 36223

The Grid, like all components that implement HasSize, has a method setHeight()

Upvotes: 1

Related Questions