diff options
author | Artur <artur@vaadin.com> | 2017-05-30 16:24:58 +0300 |
---|---|---|
committer | Ilia Motornyi <elmot@vaadin.com> | 2017-05-30 16:24:58 +0300 |
commit | 39846ae08337d55a24d3d90a6350f8e565a5c27f (patch) | |
tree | 5b77ba5236e440f7f79990b5e1372188681338a8 /server/src | |
parent | 2b9bcc62cfa0ee1d4f5da915190a8f03f076037c (diff) | |
download | vaadin-framework-39846ae08337d55a24d3d90a6350f8e565a5c27f.tar.gz vaadin-framework-39846ae08337d55a24d3d90a6350f8e565a5c27f.zip |
Allow grid columns to optionally shrink to be narrower than contents
Fixes #8548
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/main/java/com/vaadin/ui/Grid.java | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index d5bdfe45e8..3ae03679cf 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -1472,9 +1472,12 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, * This defines the minimum guaranteed pixel width of the column * <em>when it is set to expand</em>. * + * @param pixels + * the minimum width for the column * @throws IllegalStateException * if the column is no longer attached to any grid * @see #setExpandRatio(int) + * @return the column itself */ public Column<T, V> setMinimumWidth(double pixels) throws IllegalStateException { @@ -1502,6 +1505,57 @@ public class Grid<T> extends AbstractListing<T> implements HasComponents, } /** + * Sets whether the width of the contents in the column should be + * considered minimum width for this column. + * <p> + * If this is set to <code>true</code> (default for backwards + * compatibility), then a column will not shrink to smaller than the + * width required to show the contents available when calculating the + * widths (only the widths of the initially rendered rows are + * considered). + * <p> + * If this is set to <code>false</code> and the column has been set to + * expand using #setExpandRatio(int), then the contents of the column + * will be ignored when calculating the width, and the column will thus + * shrink down to the minimum width defined by #setMinimumWidth(double) + * if necessary. + * + * @param minimumWidthFromContent + * <code>true</code> to reserve space for all contents, + * <code>false</code> to allow the column to shrink smaller + * than the contents + * @return the column itself + * @throws IllegalStateException + * if the column is no longer attached to any grid + * @see #setMinimumWidth(double) + * @since + */ + public Column<T, V> setMinimumWidthFromContent( + boolean minimumWidthFromContent) throws IllegalStateException { + checkColumnIsAttached(); + + if (isMinimumWidthFromContent() != minimumWidthFromContent) { + getState().minimumWidthFromContent = minimumWidthFromContent; + getGrid().markAsDirty(); + } + return this; + } + + /** + * Gets whether the width of the contents in the column should be + * considered minimum width for this column. + * + * @return <code>true</code> to reserve space for all contents, + * <code>false</code> to allow the column to shrink smaller than + * the contents + * @see #setMinimumWidthFromContent(boolean) + * @since + */ + public boolean isMinimumWidthFromContent() { + return getState(false).minimumWidthFromContent; + } + + /** * Sets the maximum width for this column. * <p> * This defines the maximum allowed pixel width of the column <em>when |