Restoring vertical scroll position after Grid reloads data

I need to reload a Grid having for example 250 rows and about 100 columns, with new data (I’m using BeanItemContainer).
I do not want to lose the scroll position in the Grid (assuming that I’m viewing item at 200th row and 95th column).

Can anybody suggest a way to keep the vertical (and /or horizontal) scroll position?

To keep the vertical position is easier, since you can do that with scrollTo(itemId) method. In your case since you want to jump to certain index, you need to count thru your container to get 200th itemId in order to jump on that row.

However keeping the horizontal scroll position is more tricky, since there is no serverside method for that. Client side Grid has method to adjust scroll position in pixels. However if you do not have fixed column widths in your Grid, that will not work accurately. Also it would require you to make client side extension for your Grid.

You could try this simple add-on


Actually I have the same issue. I see how to call scrollTo() but how do I know which item the user has currently scrolled to (in the case there is no selection) ?