Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot reset column width of a grid #6811

Open
SonReimer opened this issue Nov 8, 2024 · 1 comment
Open

Cannot reset column width of a grid #6811

SonReimer opened this issue Nov 8, 2024 · 1 comment

Comments

@SonReimer
Copy link

SonReimer commented Nov 8, 2024

Description of the bug

If I set the width of a column, either programmatic or by user (resizable=true) and I want programmatically to reset the width to apply defaults by calling Column.setWidth(null), the column is shown with a very large width.
If I call Column.getElement().removeProperty("width") instead , the column's width is changes to its default (as width has never been set explicitly).
The problem seems to be, that Column.setWidth(String) sets the width property to null instead of removing the property.
Instead of

        public Column<T> setWidth(String width) {
            getElement().setProperty("width", width);
            return this;
        }

it should be

        public Column<T> setWidth(String width) {
            if ( width != null ) {
                getElement().setProperty("width", width);
            } else {
                getElement().removeProperty("width");
            }
            return this;
        }

Although the workaround is easy, I think it should be fixed.

Versions

  • Vaadin / Flow version: 24.5.2
  • Java version: 17
  • OS version: Windows
  • Browser version (if applicable): Chrome
  • Application Server (if applicable): Tomcat 10
  • IDE (if applicable): Eclipse
@SonReimer
Copy link
Author

Perhaps an additional method Column.setWidthUndefined() is useful ?

@mshabarov mshabarov transferred this issue from vaadin/flow Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant