Retrieve scroll position in Grid and jump to this position

Hi,

I have a lazy backend provider. I would like to change my view and go back to this view with the same scroll position.
In the grid, there is scrollTo (index of the item) but I don’t know the index of the item. (and on which index I should scroll)
I’ve seen this post (and the link in github): https://vaadin.com/forum/#!/thread/15758435/16018364
But I don’t have a solution for my problem.

Is it possible to get the current position of the grid ? (I don’t see anything in java perhaps there is something with javascript).

Here a part of “my solution” (in javascript) :
To scroll to a position, I can call this function:

private void scrollToPosition(int position) { JavaScript.getCurrent().execute("document.querySelector('div.v-grid-scroller-vertical').scrollTop = "+position+";"); } But I don’t know how to get the current position if the grid scrollbar in Java.
To get the position in javascript, I’ve got this function

position = document.querySelector('div.v-grid-scroller-vertical').scrollTop
[/code]How can I get the return value of this function ?
If i understand correctly, I can't get return value from this call [code]
JavaScript.getCurrent().execute

Thanks,

There is no such method currently, but this extension gives you those

https://vaadin.com/directory/component/gridscrollextension-add-on

Sometimes the solution is so easy :).

Thanks a lot for this add-on and your fast answer. I will test it next week :wink:

Hi,

I’ve just tried this extension and I’ve got a “bug” (I don’t know if I misuse it or not).
I created a issue on github (I hope it will be easy to reproduce): https://github.com/TatuLund/grid-scroll-extension/issues/2

Thanks,

Why not add “scrollTo(item)” to Vaadin grid?
Your addon not solve new item case.

Why important Vaadin component - “grid” with lazy load not ready for production and this problem not yet solved?