3

I have the following code running where myGridExample is a Vaadin 8 grid object.

           this.myGridExample
                    .addColumn(MapQueryService.RowResult::getFacilityType)
                    .setMinimumWidth(130)
                    .setWidth(160)
                    .setMaximumWidth(170)
                    .setCaption("Facility Type");

The setMaximumWidth(170) does not appear to do anything. however .setMinimumWidth(130) works as expected. Is this a bug?

enter image description here

1

1 Answer 1

2

From Vaadin8-docs:

setMaximumWidth

Sets the maximum width for this column. This defines the maximum allowed pixel width of the column when it is set to expand.

...

See Also: setExpandRatio(int)

If it's about setMinimumWidth - it also works only with expanding. I made some mensuration in your gif and it looks like your minimumWidth of resizing is ~110px (assuming that column at gif start position has 160px width). So it's probably adjusts by itself to longest column value.

Workaround for you:

grid.addColumnResizeListener(event -> {
   Grid.Column c = event.getColumn();
   if(c.getWidth() > c.getMaximumWidth())
      c.setWidth(c.getMaximumWidth());
   if(c.getWidth() < c.getMinimumWidth())
      c.setWidth(c.getMinimumWidth());
});

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.