summaryrefslogtreecommitdiffstats
path: root/client
diff options
context:
space:
mode:
authorLeif Åstrand <leif@vaadin.com>2013-01-14 20:38:01 +0200
committerLeif Åstrand <leif@vaadin.com>2013-01-14 20:38:01 +0200
commitcc39c3db5895fb950814b97d6db5c1712fd8e078 (patch)
treec372256c19acc51628ff4270992ea47c61cdb297 /client
parent13261dc275d1cda7ef5436d6bc6ff649c1338cb6 (diff)
downloadvaadin-framework-cc39c3db5895fb950814b97d6db5c1712fd8e078.tar.gz
vaadin-framework-cc39c3db5895fb950814b97d6db5c1712fd8e078.zip
Maintain Table scroll position when changing expand (#10489, #10106)
Change-Id: I4937d8943eab65cd4da2ec2e01af5935f96e244d
Diffstat (limited to 'client')
-rw-r--r--client/src/com/vaadin/client/ui/VScrollTable.java14
-rw-r--r--client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java21
2 files changed, 35 insertions, 0 deletions
diff --git a/client/src/com/vaadin/client/ui/VScrollTable.java b/client/src/com/vaadin/client/ui/VScrollTable.java
index 021ab8fac1..9ac9532ae4 100644
--- a/client/src/com/vaadin/client/ui/VScrollTable.java
+++ b/client/src/com/vaadin/client/ui/VScrollTable.java
@@ -268,6 +268,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
private double lastKnownRowHeight = Double.NaN;
/**
+ * Remember scroll position when getting detached to properly scroll back to
+ * the location that there is data for if getting attached again.
+ */
+ private int detachedScrollPosition = 0;
+
+ /**
* Represents a select range of rows
*/
private class SelectionRange {
@@ -1732,6 +1738,7 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
@Override
protected void onDetach() {
+ detachedScrollPosition = scrollBodyPanel.getScrollPosition();
rowRequestHandler.cancel();
super.onDetach();
// ensure that scrollPosElement will be detached
@@ -1743,6 +1750,12 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
}
}
+ @Override
+ public void onAttach() {
+ super.onAttach();
+ scrollBodyPanel.setScrollPosition(detachedScrollPosition);
+ }
+
/**
* Run only once when component is attached and received its initial
* content. This function:
@@ -7149,4 +7162,5 @@ public class VScrollTable extends FlowPanel implements HasWidgets,
public Widget getWidgetForPaintable() {
return this;
}
+
}
diff --git a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java
index 84f946dec4..c9f5b92c90 100644
--- a/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java
+++ b/client/src/com/vaadin/client/ui/orderedlayout/VAbstractOrderedLayout.java
@@ -346,11 +346,22 @@ public class VAbstractOrderedLayout extends FlowPanel {
if (expandWrapper == null) {
expandWrapper = DOM.createDiv();
expandWrapper.setClassName("v-expand");
+
+ // Detach all widgets before modifying DOM
+ for (Widget widget : getChildren()) {
+ orphan(widget);
+ }
+
while (getElement().getChildCount() > 0) {
Node el = getElement().getChild(0);
expandWrapper.appendChild(el);
}
getElement().appendChild(expandWrapper);
+
+ // Attach all widgets again
+ for (Widget widget : getChildren()) {
+ adopt(widget);
+ }
}
// Sum up expand ratios to get the denominator
@@ -395,6 +406,11 @@ public class VAbstractOrderedLayout extends FlowPanel {
*/
public void clearExpand() {
if (expandWrapper != null) {
+ // Detach all widgets before modifying DOM
+ for (Widget widget : getChildren()) {
+ orphan(widget);
+ }
+
lastExpandSize = -1;
while (expandWrapper.getChildCount() > 0) {
Element el = expandWrapper.getChild(0).cast();
@@ -409,6 +425,11 @@ public class VAbstractOrderedLayout extends FlowPanel {
}
expandWrapper.removeFromParent();
expandWrapper = null;
+
+ // Attach children again
+ for (Widget widget : getChildren()) {
+ adopt(widget);
+ }
}
}