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

benstpierre
  • 32,833
  • 51
  • 177
  • 288

1 Answers1

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());
});
Dawid Fieluba
  • 1,271
  • 14
  • 34