Search code examples
vaadinvaadin-grid

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!


Solution

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