disable Grid columns (header) resizable

How to disable the possibility of dragging columns (headers) and avoid to change they width, I want to do this because as documentation says:

The user can resize columns by dragging their separators with the mouse. When resized manually, all the columns widths are set to explicit pixel values, even if they had relative values before.

Once a column is resize, the Grid loses the auto-width-adjustment and the Grid gets a gap in the right size. I couldn’t find a way to rollback the state of the column width without reload the GUI

Using: Vaadin 8.4

Grid.Column has method [setResizable]
(https://vaadin.com/download/release/8.4/8.4.1/docs/api/com/vaadin/ui/Grid.Column.html#setResizable-boolean-), so if you set all columns setResizable(false) then user cannot resize the columns.

Alternatively you should be able to set all [columns to undefined width]
(https://vaadin.com/download/release/8.4/8.4.1/docs/api/com/vaadin/ui/Grid.Column.html#setWidthUndefined--), after which auto-width-adjustment of the columns happens again when you call Grid.[recalculateColmnWidths]
(https://vaadin.com/download/release/8.4/8.4.1/docs/api/com/vaadin/ui/Grid.html#recalculateColumnWidths--)().

Third alternative is to use [Grid Scroll Extension]
(https://vaadin.com/directory/component/gridscrollextension-add-on) add-on, which makes it possible to auto-adjust the width of the Grid itself according to sum of column widths.

Thanks, Idk how I missed setResizable().
I am trying now the add-on but doesn’t seems to work. Grid should (or not) has some kind of setting to make this extension works? The grid is in a VerticalLayout, which is setSizeFull() too

I have the following column setting:

1st .setHidden(true);
2nd .setResizable(false).setSortable(false).setMaximumWidth(100).setExpandRatio(1);
3rd and 4th .setSortable(false).setExpandRatio(3);
5th .setResizable(false).setSortable(false);

I just added:
new GridScrollExtension(grid).setAutoResizeWidth(true);

I am trying now the add-on but doesn’t seems to work.

Did you recompile the widgetset?

I cloned your example from github (branch vaadin8), but the autoResizeWidth is not what I expected, it shrinks the Grid while a column lose width, it doesn’t make others columns to take the “available” space. Sorry if I misunderstood what the add-on suppose to do

17082006.png

it shrinks the Grid while a column lose width

Yes, that is how it works.

it doesn’t make others columns to take the “available” space

I had three options in my original answer, the second should do what you are looking for, i.e. : “Alternatively you should be able to set all columns to undefined width, after which auto-width-adjustment of the columns happens again when you call Grid.recalculateColmnWidths().”