View Full Version : Scrolling issues in Grid when using LiveGridView

29 Mar 2017, 12:55 AM
Many methods related to scroll do not work when usingLiveGridView: syncScroll(), scrollToTop(boolean), getScrollState(), restoreScroll(Point).
We did not have problems here with GXT3.1.4, but we migrated to GXT 4.0.2 and faced this issue.
From my understanding, it is because liveScroller should be used for vertical scroll and scroller should be used for horizontal scroll.
So, these methods should be overridden in LiveGridView.
Currently, only scrollToTop() is overridden, which should not be needed if scrollToTop(boolean) were overridden.
The change is to use liveScroller for vertical scrolling and scroller for horizontal scrolling.
For restoreScroll I had to do some more changes, as I do not understand current code.

I copied below a simple update which can be included in LiveGridView.
Exisintg method public void scrollToTop() can be removed.
It would also be possible to manage this at the GridView level, by creating separate methods for getVerticalScroller() and getHorizontalScroller() instead of the single getScroller(), but it could lead to regressions in third-party code.

protected void syncScroll() {
int scrollLeft = scroller.getScrollLeft();
int scrollTop = liveScroller.getScrollTop(); // must use liveScroller here
grid.fireEvent(new BodyScrollEvent(scrollLeft, scrollTop));
* Scrolls the grid the top.
* @param resetHorizontal true to reset horizontal
public void scrollToTop(boolean resetHorizontal) {
if (resetHorizontal) {
* Returns the current scroll state.
* @return the scroll state
public Point getScrollState() {
return new Point(scroller.getScrollLeft(), liveScroller.getScrollTop());
protected void restoreScroll(Point state) {
// not sure why scroller.getWidth(false) returns only visible area and not total width
if (state.getX() < getTotalWidth()) {
if (state.getY() < liveScroller.getHeight(false)) {