Listen for scrollbar events in a Panel

I’ve looked through the API and searched the forums but cannot figure out how to listen for scrollbar events in a Panel to be able to scroll related components by the same amount.

So for instance I have a HorizontalLayout above a Panel containing a GridLayout both of which are too wide for the screen. The Panel has a scrollbar. I can scroll it and the GridLayout contents scroll nicely. Now I want the HorizontalLayout just above this to behave like column headers and scroll with it by getting the scroll position of the Panel and setting it for the HorizontalLayout. Does this make sense and would it even be possible? Does the HorizontalLayout also have to be wrapped inside a Panel and if so, can it hide the scrollbar?

I just cannot figure out what to listen to in the Panel. Which event or action is fired when the user scrolls? I’ve posted in another thread that maybe all this can be done using a Table, though I’m not sure, but I’d still like to know how to capture scrolling events.

Hi Brad,

The scroll values are sent back to the server, but only “lazily”, i.e. when some other event/update gets sent to server.

Even if the values would get sent to the server immediately after the scroll, there’s currently no event for them, and the update from the client side is done internally, so overriding Panel.setScrollTop won’t help.

I think this is worthy of an enhancement ticket, could you add one to our issue tracker at
dev.vaadin.com
, thanks!

Jouni,

I’ve created ticket #4163 for this.

Brad