Is there anyway of getting/setting the scroll position of a Handsontable

Hi,

Is there anyway of getting/setting the scroll position of a Handsontable i.e. in JS you could use

var elmnt = document.getElementById("???");
var x = elmnt.scrollLeft;
var y = elmnt.scrollTop;

If the above code is possible, what ElementById would you use.

I am trying to set the Handsontable scroll position when initializing the page.

Thanks for any help.

Hi Ben,

you can use scrollViewportTo method. Here’s how it works http://jsfiddle.net/0ubtkvwc/

Hi

Thank you for this. How would i get the scrollViewportTo(50, 50) settings i.e. 50 and 50, I am re-initializing the page, and need the values that were set before the reload.

Thanks

Sorry, but I do not understand. The demo that I have sent you scrolls the table to 50,50 coordinates. If you would like to track what user selected and get back to his selection that you would need to store afterSelectionEnd hook values

Hi,

Your example shows how to set a scroll position, but not how to get the current scroll position; so it can be reloaded in after i re-initialize the page.

background:
I am re-initializing a page, as handsontable was to slow at doing everything I wanted it to do and pushed it to the back end, as there will only ever be one or two users of my software. (very fast)

You’re right, we do not store a scroll position only a first/last visible column or row. If that meets your project requirements you can find it at

Column
https://docs.handsontable.com/pro/1.18.1/AutoColumnSize.html#getFirstVisibleColumn
https://docs.handsontable.com/pro/1.18.1/AutoColumnSize.html#getLastVisibleColumn

Row
https://docs.handsontable.com/pro/1.18.1/AutoRowSize.html#getFirstVisibleRow
https://docs.handsontable.com/pro/1.18.1/AutoRowSize.html#getLastVisibleRow

I think I got the wrong end of the stick slightly !! This helps thank you.

Glad I could help one way or another :slight_smile:
Feel free to ask me anything.