autoWidth="true" not working on new columns

Hi,
In DataGrids, when we add a column through the gridColumnVisibility
image
Then the autoWidth=“true” is not taken into account. This leads to column being very tiny and the filter button is not visible without manual resize.
image
I hope you can to something for that.
Best regards

In addition, the last column is a pain to resize as it is a at the border of the screen. I know that this one is not easy to solve but it makes the main problem even more problematic.

Hello!

Thank you for reporting the problem! I’ve created an issue in GitHub: Hidden Grid column with autoWidth enabled does not adjust its width to fit its content when it becomes visible · Issue #4532 · jmix-framework/jmix · GitHub.

The reason of this behavior is described in JavaDocs Grid.Column#setAutoWidth(boolean):

For performance reasons the column width is calculated automatically only once when the grid items are rendered for the first time and the calculation only considers the rows which are currently rendered in DOM (a bit more than what is currently visible). If the grid is scrolled, or the cell content changes, the column width might not match the contents anymore.
Hidden columns are ignored in the calculation and their widths are not automatically updated when you show a column that was initially hidden.
You can manually trigger the auto sizing behavior again by calling recalculateColumnWidths().