Skip to content

Commit 482b40b

Browse files
committed
Fix issue #7058: WTableView displays "Loading" when resized...
Adapted from a patch provided by Bruce Toll. I chose to go with putting the initial scroll functionality into the wtResize of WTableView.js, rather than splitting up wtResize.
1 parent 8663166 commit 482b40b

File tree

3 files changed

+29
-32
lines changed

3 files changed

+29
-32
lines changed

src/Wt/WTableView.C

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -791,13 +791,16 @@ void WTableView::defineJavaScript()
791791

792792
LOAD_JAVASCRIPT(app, "js/WTableView.js", "WTableView", wtjs1);
793793

794-
setJavaScriptMember(" WTableView", "new " WT_CLASS ".WTableView("
795-
+ app->javaScriptClass() + "," + jsRef() + ","
796-
+ contentsContainer_->jsRef() + ","
797-
+ headerContainer_->jsRef() + ","
798-
+ headerColumnsContainer_->jsRef() + ",'"
799-
+ WApplication::instance()->theme()->activeClass()
800-
+ "');");
794+
WStringStream s;
795+
s << "new " WT_CLASS ".WTableView("
796+
<< app->javaScriptClass() << ',' << jsRef() << ','
797+
<< contentsContainer_->jsRef() << ','
798+
<< viewportTop_ << ','
799+
<< headerContainer_->jsRef() << ','
800+
<< headerColumnsContainer_->jsRef() << ",'"
801+
<< WApplication::instance()->theme()->activeClass()
802+
<< "');";
803+
setJavaScriptMember(" WTableView", s.str());
801804

802805
if (!dropEvent_.isConnected())
803806
dropEvent_.connect(this, &WTableView::onDropEvent);
@@ -813,18 +816,6 @@ void WTableView::defineJavaScript()
813816
columnResizeConnected_ = true;
814817
}
815818

816-
if (viewportTop_ != 0) {
817-
WStringStream s;
818-
s << "function(o, w, h) {"
819-
<< "if (!o.scrollTopSet) {"
820-
<< "o.scrollTop = " << viewportTop_ << ";"
821-
<< "o.onscroll();"
822-
<< "o.scrollTopSet = true;"
823-
<< "}"
824-
<< "}";
825-
contentsContainer_->setJavaScriptMember(WT_RESIZE_JS, s.str());
826-
}
827-
828819
if (canvas_) {
829820
app->addAutoJavaScript
830821
("{var obj = " + jsRef() + ";"

src/js/WTableView.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
WT_DECLARE_WT_MEMBER
1010
(1, JavaScriptConstructor, "WTableView",
11-
function(APP, el, contentsContainer, headerContainer, headerColumnsContainer,
11+
function(APP, el, contentsContainer, initialScrollTop, headerContainer, headerColumnsContainer,
1212
selectedClass) {
1313
el.wtObj = this;
1414

@@ -33,6 +33,7 @@ WT_DECLARE_WT_MEMBER
3333

3434
var scrollX1 = 0, scrollX2 = 0, scrollY1 = 0, scrollY2 = 0;
3535
var scrollToPending = false;
36+
var initialScrollTopSet = initialScrollTop === 0;
3637

3738
/*
3839
* We need to remember this for when going through a hide()
@@ -66,6 +67,11 @@ WT_DECLARE_WT_MEMBER
6667
};
6768

6869
contentsContainer.wtResize = function(o, w, h, setSize) {
70+
if (!initialScrollTopSet) {
71+
o.scrollTop = initialScrollTop;
72+
o.onscroll();
73+
initialScrollTopSet = true;
74+
}
6975
if ((w - currentWidth) > (scrollX2 - scrollX1)/2 ||
7076
(h - currentHeight) > (scrollY2 - scrollY1)/2) {
7177
currentWidth = w; currentHeight = h;

src/js/WTableView.min.js

Lines changed: 12 additions & 12 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)