diff options
author | Anna Koskinen <anna@vaadin.com> | 2016-06-01 11:56:34 +0300 |
---|---|---|
committer | Johannes Dahlström <johannesd@vaadin.com> | 2016-06-29 12:43:16 +0000 |
commit | edad7348bb8eba807225bfa72d4b0a4342426c71 (patch) | |
tree | 4eefaf917c8ef6ab7c7c250597de32b94c8a4fe5 /client | |
parent | 75b282c319b2783d0ea2737727081c6923342ac0 (diff) | |
download | vaadin-framework-edad7348bb8eba807225bfa72d4b0a4342426c71.tar.gz vaadin-framework-edad7348bb8eba807225bfa72d4b0a4342426c71.zip |
Updates to Grid's height handling (#19690).
- new height more for undefined height that works like in Table and
resizes the grid when details row opens or closes
Change-Id: I2dc817140308093865be30de72edcd6494e4a44b
Diffstat (limited to 'client')
-rw-r--r-- | client/src/main/java/com/vaadin/client/widgets/Escalator.java | 38 | ||||
-rw-r--r-- | client/src/main/java/com/vaadin/client/widgets/Grid.java | 8 |
2 files changed, 41 insertions, 5 deletions
diff --git a/client/src/main/java/com/vaadin/client/widgets/Escalator.java b/client/src/main/java/com/vaadin/client/widgets/Escalator.java index 29b7eb6d53..25e83592d7 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Escalator.java +++ b/client/src/main/java/com/vaadin/client/widgets/Escalator.java @@ -1148,6 +1148,9 @@ public class Escalator extends Widget implements RequiresResize, assertArgumentsAreValidAndWithinRange(index, numberOfRows); rows -= numberOfRows; + if (heightMode == HeightMode.UNDEFINED) { + heightByRows = rows; + } if (!isAttached()) { return; @@ -1271,6 +1274,9 @@ public class Escalator extends Widget implements RequiresResize, } rows += numberOfRows; + if (heightMode == HeightMode.UNDEFINED) { + heightByRows = rows; + } /* * only add items in the DOM if the widget itself is attached to the @@ -5826,7 +5832,13 @@ public class Escalator extends Widget implements RequiresResize, if (height != null && !height.isEmpty()) { heightByCss = height; } else { - heightByCss = DEFAULT_HEIGHT; + if (getHeightMode() == HeightMode.UNDEFINED) { + heightByRows = body.getRowCount(); + applyHeightByRows(); + return; + } else { + heightByCss = DEFAULT_HEIGHT; + } } if (getHeightMode() == HeightMode.CSS) { @@ -5840,7 +5852,16 @@ public class Escalator extends Widget implements RequiresResize, if (height != null && !height.isEmpty()) { super.setHeight(height); } else { - super.setHeight(DEFAULT_HEIGHT); + if (getHeightMode() == HeightMode.UNDEFINED) { + int newHeightByRows = body.getRowCount(); + if (heightByRows != newHeightByRows) { + heightByRows = newHeightByRows; + applyHeightByRows(); + } + return; + } else { + super.setHeight(DEFAULT_HEIGHT); + } } recalculateElementSizes(); @@ -6318,7 +6339,7 @@ public class Escalator extends Widget implements RequiresResize, * define its height that way. */ private void applyHeightByRows() { - if (heightMode != HeightMode.ROW) { + if (heightMode != HeightMode.ROW && heightMode != HeightMode.UNDEFINED) { return; } @@ -6327,9 +6348,13 @@ public class Escalator extends Widget implements RequiresResize, double bodyHeight = body.getDefaultRowHeight() * heightByRows; double scrollbar = horizontalScrollbar.showsScrollHandle() ? horizontalScrollbar .getScrollbarThickness() : 0; + double spacerHeight = 0; // ignored if HeightMode.ROW + if (heightMode == HeightMode.UNDEFINED) { + spacerHeight = body.spacerContainer.getSpacerHeightsSum(); + } - double totalHeight = headerHeight + bodyHeight + scrollbar - + footerHeight; + double totalHeight = headerHeight + bodyHeight + spacerHeight + + scrollbar + footerHeight; setHeightInternal(totalHeight + "px"); } @@ -6370,6 +6395,9 @@ public class Escalator extends Widget implements RequiresResize, case ROW: setHeightByRows(heightByRows); break; + case UNDEFINED: + setHeightByRows(body.getRowCount()); + break; default: throw new IllegalStateException("Unimplemented feature " + "- unknown HeightMode: " + this.heightMode); diff --git a/client/src/main/java/com/vaadin/client/widgets/Grid.java b/client/src/main/java/com/vaadin/client/widgets/Grid.java index 93aeac0d68..7665111416 100644 --- a/client/src/main/java/com/vaadin/client/widgets/Grid.java +++ b/client/src/main/java/com/vaadin/client/widgets/Grid.java @@ -3600,6 +3600,9 @@ public class Grid<T> extends ResizeComposite implements } escalator.getBody().setSpacer(rowIndex, spacerHeight); + if (getHeightMode() == HeightMode.UNDEFINED) { + setHeightByRows(getEscalator().getBody().getRowCount()); + } } @Override @@ -3628,6 +3631,11 @@ public class Grid<T> extends ResizeComposite implements setParent(detailsWidget, null); spacerElement.removeAllChildren(); + if (getHeightMode() == HeightMode.UNDEFINED) { + // update spacer height + escalator.getBody().setSpacer(spacer.getRow(), 0); + setHeightByRows(getEscalator().getBody().getRowCount()); + } } } |