From 7cf466fa7f0a1fbf48664a6c8211809f9932a997 Mon Sep 17 00:00:00 2001 From: Teemu Suo-Anttila Date: Tue, 1 Aug 2017 11:41:39 +0300 Subject: Add header and footer visibility setting to Grid (#9706) --- server/src/main/java/com/vaadin/ui/Grid.java | 46 ++++++++++++++++++++++ .../vaadin/ui/components/grid/StaticSection.java | 24 +++++++++++ 2 files changed, 70 insertions(+) (limited to 'server') diff --git a/server/src/main/java/com/vaadin/ui/Grid.java b/server/src/main/java/com/vaadin/ui/Grid.java index dbaff46181..70e947ccd8 100644 --- a/server/src/main/java/com/vaadin/ui/Grid.java +++ b/server/src/main/java/com/vaadin/ui/Grid.java @@ -3206,6 +3206,29 @@ public class Grid extends AbstractListing implements HasComponents, getHeader().removeRow(index); } + /** + * Sets the visibility of the Header in this Grid. + * + * @param headerVisible + * {@code true} if visible; {@code false} if not + * + * @since 8.1.1 + */ + public void setHeaderVisible(boolean headerVisible) { + getHeader().setVisible(headerVisible); + } + + /** + * Gets the visibility of the Header in this Grid. + * + * @return {@code true} if visible; {@code false} if not + * + * @since 8.1.1 + */ + public boolean isHeaderVisible() { + return getHeader().isVisible(); + } + /** * Returns the current default row of the header. * @@ -3356,6 +3379,29 @@ public class Grid extends AbstractListing implements HasComponents, getFooter().removeRow(index); } + /** + * Sets the visibility of the Footer in this Grid. + * + * @param footerVisible + * {@code true} if visible; {@code false} if not + * + * @since 8.1.1 + */ + public void setFooterVisible(boolean footerVisible) { + getFooter().setVisible(footerVisible); + } + + /** + * Gets the visibility of the Footer in this Grid. + * + * @return {@code true} if visible; {@code false} if not + * + * @since 8.1.1 + */ + public boolean isFooterVisible() { + return getFooter().isVisible(); + } + /** * Returns the footer section of this grid. * diff --git a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java index 947be8f522..da5cafb9d6 100644 --- a/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java +++ b/server/src/main/java/com/vaadin/ui/components/grid/StaticSection.java @@ -798,4 +798,28 @@ public abstract class StaticSection> return Collections.unmodifiableList(rows); } + /** + * Sets the visibility of this section. + * + * @param visible + * {@code true} if visible; {@code false} if not + * + * @since 8.1.1 + */ + public void setVisible(boolean visible) { + if (getState(false).visible != visible) { + getState(true).visible = visible; + } + } + + /** + * Gets the visibility of this section. + * + * @return {@code true} if visible; {@code false} if not + * + * @since 8.1.1 + */ + public boolean isVisible() { + return getState(false).visible; + } } -- cgit v1.2.3