Is there a way to get each row's height of the Grid?

I am using vaadin 14.

Originally, all the rows have the same height which is 20px, so I was able to set my max-height for the Grid using:

int maxHeight =  (data.size() * 20) + 100;
myGrid.getStyle().set("max-height", maxHeight + "px");

But now I add multi-select to my grid, and some row will increase their height if user select multiple selections.

Is there a way for me to get each individual row’s height so that I can calculate the correct height for the Grid?

If you don’t have thousands of rows; why not let Grid handle it itself? Grid::setAllRowsVisible(true)

Your solution works as expected, adjusting the table height dynamically.

What if I do have thousands of rows? Also, my clients have different screens resolutions. I think that the height of rows change accordingly, right?

I would say: don’t care about the row height. Let the grid grow based on the available screen size (e.g. add it to your layout with addAndExpand())