How to get scroll events or table row draw events

223 views
Skip to first unread message

RonS

unread,
May 29, 2006, 12:34:35 AM5/29/06
to Google Web Toolkit
I want to implement a scrolling Grid that has a large number of rows
and fetches the content of the rows asynchronously as needed from the
server.

I constructed a Grid widget within a ScrollPane, which works great.
I'd like to either get events for when table rows need to be drawn, or
when the scroll pane is scrolled to a new position so I can fetch new
data from the server if needed.

I see ScrollListener and SourcesScrollEvents interfaces in the gwt
reference, but I don't see anything that implements the
SourcesScrollEvents interface, which is what I think I need.
Is there a way to register a ScrollListener with a ScrollPane?

Is there a way to get notified prior to a row/cell of a table needing
to get rendered? I tried overriding the prepareCell function, but that
didn't seem to do it.

Thanks
Ron

crumbledust

unread,
May 29, 2006, 3:10:37 AM5/29/06
to Google Web Toolkit
You appear to be right (assuming the documentation is correct).
ScrollPanel doesn't implement SourcesScrollEvents, which means you
can't add a scroll listener: that sounds like a bug.

Joel Webber

unread,
May 30, 2006, 5:38:27 PM5/30/06
to Google-We...@googlegroups.com
It is indeed!  Adding this to the issues list.

You can work around this temporarily by subclassing ScrollPanel and adding an implementation of onBrowserEvent(), like so:

    public void onBrowserEvent(Event event) {
      if (DOM.eventGetType(event) == Event.ONSCROLL) {
        // Do something, using getScrollPosition().
      } else {
        super.onBrowserEvent(event);
      }
    }

joel.

graff...@gmail.com

unread,
Jun 22, 2006, 11:59:13 AM6/22/06
to Google Web Toolkit
I tried Joel Webber's approach... it didn't work. my subclass of
ScrollPanel never got it's "onBrowserEvent" called.

- Bob

cole...@gmail.com

unread,
Jun 22, 2006, 3:47:24 PM6/22/06
to Google Web Toolkit
Bob:
It took me a while to realize that you have to call
scrollPanel.sinkEvents(Event.ONSCROLL)

graff...@gmail.com

unread,
Jun 22, 2006, 7:34:22 PM6/22/06
to Google Web Toolkit
Great...thanks...it works!!

djsch...@mitre.org

unread,
Jun 27, 2006, 4:55:17 PM6/27/06
to Google Web Toolkit
This seems very useful to me. I want to do something similar where
have a grid, say 4x4, and I want to use the scroll bar as shown with
the onBrowserEvent, except that it wouldn't actually scroll the grid,
but populate it with new data to simulate scrolling. My question is,
how can I get the scroll bar to appear and register scroll events if
its not really scrolling? Basically, I want the scroll bar just so I
can call the onBrowserEvent() method with code to repopulate the grid.
Any suggestions?

Thanks,
Dan

Reply all
Reply to author
Forward
0 new messages