Export to GitHub

google-web-toolkit - issue #6865

DataGrid should expose its scrollpane.


Posted on Oct 7, 2011 by Grumpy Ox

Found in GWT Release (e.g. 2.4.0, 2.5.0 RC): GWT 2.4.0

Encountered on OS / Browser (e.g. WinXP, IE8-9, FF7): Not applicable.

Detailed description (please be as specific as possible): DataGrid should expose its scrollpane. Without access to the scrollpane it is not possible for example to reset the scroll position when changing the content of the grid.

I have two grids side by side (see http://code.google.com/p/bug4j/ ) and when the selection changes on the left, the content changes on the right.

Workaround if you have one: final DataGrid<BugHit> ret = new DataGrid<BugHit>(PAGE_SIZE){ @Override public void setRowData(int start, List<? extends BugHit> values) { final HeaderPanel headerPanel = (HeaderPanel) getWidget(); final ScrollPanel scrollPanel = (ScrollPanel) headerPanel.getContentWidget(); scrollPanel.scrollToTop(); super.setRowData(start, values); } };

Links to relevant GWT Developer Forum posts: http://groups.google.com/group/google-web-toolkit/browse_thread/thread/c35e5841379ab85f#

Link to patch posted at http://gwt-code-reviews.appspot.com:

Comment #1

Posted on Oct 7, 2011 by Grumpy Hippo

(No comment was entered for this change.)

Comment #2

Posted on Oct 9, 2011 by Massive Lion

I have another use case that needs an access to scroll panel. I need DataGrid rows to be rendered lazily (once they are in the visible view of the scroll panel).

In my use case a singe page could have hundreds of item (whereas total size of the table could be billions). The problem is that it is too costly to fetch contents of all hundred items on a page at once. I would rather display fully detailed data for the visible scroll window, and display the rest of the rows as placeholders. With the current DataGrid it is all very doable if the Scroll event could be caught. Then it is just a matter of calculating a range of visible rows (using dataGrid.getRowElement() and replacing row range using setRowData())

Comment #3

Posted on Oct 10, 2011 by Massive Cat

We can expose the ScrollPanel.

The reason it isn't exposed is because DataGrid won't actually work with any ScrollPanel, or even with a ScrollPanel widget. The width of the content area of the scroll panel must equal that of the header and footer, or the columns won't line up correctly. CustomScrollPanel does this because it overlays the scrollbars on top of the content area. A native ScrollPanel shrinks the content area by 15 pixels, which messes up column width calculations. We can add some JavaDoc to explain this.

Comment #4

Posted on Oct 10, 2011 by Massive Lion

Thanks. The quick temp. workaround for now is to inherit from DataGrid and add a method:

public ScrollPanel getScrollPanel() {
    HeaderPanel header = (HeaderPanel) getWidget();
    return (ScrollPanel) header.getContentWidget();
}

Comment #5

Posted on Oct 14, 2011 by Happy Giraffe

Wouldn't it be easier to add something like scrollToTop()?

Comment #6

Posted on Nov 17, 2011 by Happy Bear

It's not just a issue with scrollToTop. Access to the scrollpanel would also allow add ing scroll handler so one could request new data from the server

Comment #7

Posted on May 11, 2012 by Swift Rhino

Issue 7368 has been merged into this issue.

Comment #8

Posted on May 16, 2012 by Massive Bird

This workaround is sweet. I had a really hard time figuring that out myself.

Comment #9

Posted on Nov 8, 2012 by Swift Rhino

http://gwt-code-reviews.appspot.com/1864803/

Comment #10

Posted on Nov 9, 2012 by Swift Rhino

Related: issue 7589

Comment #11

Posted on Nov 29, 2012 by Swift Rhino

Review was change substantially and no longer address this issue.

Comment #12

Posted on Mar 27, 2013 by Happy Cat

Comment deleted

Comment #13

Posted on Apr 30, 2013 by Swift Elephant

Why not just have the DataGrid implement HasScrolling?

Comment #14

Posted on Jun 10, 2015 by Massive Cat

Issue tracked moved to github, see https://github.com/gwtproject/gwt/issues

Status: MovedToGithub