1

I'm using gwt; and I have two grids in my page. They have the same count of rows with diff contents.

I want that, when I scroll grid1,grid2 auto scroll to the same place.

Can anyone help?

I tried like this, but this event doesn't fire.

grid1.addBodyScrollHandler(new BodyScrollHandler()
    {
        @Override
        public void onBodyScroll(BodyScrollEvent event)
        {
            Info.display("test", event.getScrollTop() + "");
            //if this event fires,how to scroll grid2
        }
    });
Pang
  • 9,564
  • 146
  • 81
  • 122
Elan.Cao
  • 75
  • 10

2 Answers2

0

You can follow the approach as like this:

  • Add two GridListeners to each of the GRIDS that you want on your UI
  • Implement a handler for onScroll event of the first grid and add functionality to scroll the second grid

A similar implementation of the problem that you've asked has been implemented with GWT-EXT, hope that this link provides you with the basic idea though the code given there might not help you completely!

N00b Pr0grammer
  • 4,503
  • 5
  • 32
  • 46
0

From https://stackoverflow.com/a/15048539/860630, which goes into a little more depth on other parts of this general issue:

  grid1.addBodyScrollHandler(new BodyScrollHandler() {
    @Override
    public void onBodyScroll(BodyScrollEvent event) {
      grid2.getView().getScroller().scrollTo(ScrollDirection.TOP, event.getScrollTop());
    }
  });
  grid2.addBodyScrollHandler(new BodyScrollHandler() {
    @Override
    public void onBodyScroll(BodyScrollEvent event) {
      grid1.getView().getScroller().scrollTo(ScrollDirection.TOP, event.getScrollTop());
    }
  });
Community
  • 1
  • 1
Colin Alworth
  • 17,801
  • 2
  • 26
  • 39