Vaadin version: 8.1.4
My problem is that after resizing the screen the grid is not resized properly. I use setSizeFull() for a grid. After resizing the browser grid, however, retains its original size.
The next code sample seems to do the trick, but I wonder if there is a better method.
UI.getCurrent().getPage().addBrowserWindowResizeListener(e -> {
grid.recalculateColumnWidths();
});
P.S. I forgot to mention, the problem with current solution is that in case of very long texts for fields vaadin tries to adjust the grid so that all the text will fit, which results in grid having more than 100% of width.
Example:
Grid<MyObject> = new Grid();
grid.addColumn(MyObject::getDescription).setCaption("Caption").setSortable(false);
Css styling for grid cell:
.v-grid-cell {
white-space: nowrap;
overflow: hidden;
}
Without recalculating column widths the grid fits nicely into the page no matter what is the size of the MyObject description, but after the recalculation(in case the MyObject descrtiption does not fit into the browser window) the grid is wider than the window.