diff options
3 files changed, 52 insertions, 1 deletions
diff --git a/client/src/com/vaadin/client/widgets/Grid.java b/client/src/com/vaadin/client/widgets/Grid.java index 3271f51656..3cc02e763c 100644 --- a/client/src/com/vaadin/client/widgets/Grid.java +++ b/client/src/com/vaadin/client/widgets/Grid.java @@ -2992,8 +2992,9 @@ public class Grid<T> extends ResizeComposite implements for (Column<?, T> column : nonFixedColumns) { final int expandRatio = (defaultExpandRatios ? 1 : column .getExpandRatio()); - final double newWidth = column.getWidthActual(); final double maxWidth = getMaxWidth(column); + final double newWidth = Math.min(maxWidth, + column.getWidthActual()); boolean shouldExpand = newWidth < maxWidth && expandRatio > 0 && column != selectionColumn; if (shouldExpand) { @@ -3012,6 +3013,7 @@ public class Grid<T> extends ResizeComposite implements double pixelsToDistribute = escalator.getInnerWidth() - reservedPixels; if (pixelsToDistribute <= 0 || totalRatios <= 0) { + setColumnSizes(columnSizes); return; } diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java index 23226fb6cf..479ece71ca 100644 --- a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/GridBasicFeatures.java @@ -1174,6 +1174,18 @@ public class GridBasicFeatures extends AbstractComponentTest<Grid> { } }); + + createClickAction("All columns expanding, Col 0 has max width of 30px", + "Columns", new Command<Grid, Boolean>() { + + @Override + public void execute(Grid c, Boolean value, Object data) { + for (Column col : grid.getColumns()) { + col.setWidthUndefined(); + } + grid.getColumns().get(0).setMaximumWidth(30); + } + }, null); } private static String getColumnProperty(int c) { diff --git a/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnMaxWidthTest.java b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnMaxWidthTest.java new file mode 100644 index 0000000000..dffa22fdc6 --- /dev/null +++ b/uitest/src/com/vaadin/tests/components/grid/basicfeatures/server/GridColumnMaxWidthTest.java @@ -0,0 +1,37 @@ +/* + * Copyright 2000-2014 Vaadin Ltd. + * + * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of + * the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations under + * the License. + */ +package com.vaadin.tests.components.grid.basicfeatures.server; + +import static org.junit.Assert.assertEquals; + +import org.junit.Test; + +import com.vaadin.tests.components.grid.basicfeatures.GridBasicFeaturesTest; + +public class GridColumnMaxWidthTest extends GridBasicFeaturesTest { + + @Test + public void testRemovingAllColumns() { + setDebug(true); + openTestURL(); + + selectMenuPath("Component", "Columns", + "All columns expanding, Col 0 has max width of 30px"); + + assertEquals("Column 0 did not obey max width of 30px.", "30px", + getGridElement().getCell(0, 0).getCssValue("width")); + } +}
\ No newline at end of file |