diff options
author | Pekka Hyvönen <pekka@vaadin.com> | 2015-03-23 13:42:07 +0200 |
---|---|---|
committer | Pekka Hyvönen <pekka@vaadin.com> | 2015-03-31 13:51:09 +0000 |
commit | 0e7755958b46434185cb1e6e2ec8aa6932b32f34 (patch) | |
tree | 4e39eb62bcab3c2a03a3cc5d7b98e60e1ab943fb /server/src | |
parent | 844b2c6c41d57d4db1238eb6096f225c9fdb8314 (diff) | |
download | vaadin-framework-0e7755958b46434185cb1e6e2ec8aa6932b32f34.tar.gz vaadin-framework-0e7755958b46434185cb1e6e2ec8aa6932b32f34.zip |
API for column hiding toggle caption in Grid (#17272)
Fixes column toggle not getting a caption when a hidable column is added.
Fixes column toggle not getting a caption on columns with widget in header.
Change-Id: Ie10ada793a3635302603f684f232cadaef74a982
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/com/vaadin/ui/Grid.java | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/server/src/com/vaadin/ui/Grid.java b/server/src/com/vaadin/ui/Grid.java index 2cb7ab352a..cd97e90e2e 100644 --- a/server/src/com/vaadin/ui/Grid.java +++ b/server/src/com/vaadin/ui/Grid.java @@ -2286,6 +2286,46 @@ public class Grid extends AbstractComponent implements SelectionNotifier, } /** + * Gets the caption of the hiding toggle for this column. + * + * @since + * @see #setHidingToggleCaption(String) + * @return the caption for the hiding toggle for this column + * @throws IllegalStateException + * if the column is no longer attached to any grid + */ + public String getHidingToggleCaption() throws IllegalStateException { + checkColumnIsAttached(); + return state.hidingToggleCaption; + } + + /** + * Sets the caption of the hiding toggle for this column. Shown in the + * toggle for this column in the grid's sidebar when the column is + * {@link #isHidable() hidable}. + * <p> + * By default, before triggering this setter, a user friendly version of + * the column's {@link #getPropertyId() property id} is used. + * <p> + * <em>NOTE:</em> setting this to <code>null</code> or empty string + * might cause the hiding toggle to not render correctly. + * + * @since + * @param hidingToggleCaption + * the text to show in the column hiding toggle + * @return the column itself + * @throws IllegalStateException + * if the column is no longer attached to any grid + */ + public Column setHidingToggleCaption(String hidingToggleCaption) + throws IllegalStateException { + checkColumnIsAttached(); + state.hidingToggleCaption = hidingToggleCaption; + grid.markAsDirty(); + return this; + } + + /** * Returns the width (in pixels). By default a column is 100px wide. * * @return the width in pixels of the column @@ -3860,8 +3900,10 @@ public class Grid extends AbstractComponent implements SelectionNotifier, header.addColumn(datasourcePropertyId); footer.addColumn(datasourcePropertyId); - column.setHeaderCaption(SharedUtil.propertyIdToHumanFriendly(String - .valueOf(datasourcePropertyId))); + String humanFriendlyPropertyId = SharedUtil + .propertyIdToHumanFriendly(String.valueOf(datasourcePropertyId)); + column.setHeaderCaption(humanFriendlyPropertyId); + column.setHidingToggleCaption(humanFriendlyPropertyId); return column; } |