Scroll to previously scrolled location

Tags: #<Tag:0x00007fa9944399b0>

Is there a possibility to scroll table to certain point? The case is that row header click redirects user to object details view, the object id is saved to sessionStorage like so:
image

After coming back to the hot-view, the table has to scroll to the same row where user last clicked off.
I was thinking about using [afterLoadData] but I can’t get the physical location of sourceRow, after which I should use ‘selectCell’ plugin?

Is the afterLoadData approach right and if so, how can I get location from hotTable which has data hotTable.getSourceDataAtRow(previousSelected)

Hey @karl

the selectCell is a good way to scroll the viewport. You also have the scrollViewportTo method. I’m just not sure about the afterLoadData. Do you update data in Handsontable after you save into sessionStorage?

I only save objectId to sessionStorage, data will be reimported when handsontable view gets initialized.


currently scrollViewPortTo gives “ERROR TypeError: Cannot read property ‘scrollViewport’ of undefined”

The scrollViewportTo is a core method. Maybe the hotTable variable is undefined at this point? Can you log it?

used afterInit and calling scrollToPrevious function. But I think hotTable.scrollViewportTo(previousSelected, 0);
may not be linked on the same table instance? At the moment it doesn’t throw error or anything, but does not scroll to row “previuosSelected” also.

logging (hotTable.scrollViewportTo(previousSelected, 0)) returns true, so it should be able to scroll?

Did a little hack, 100ms timeout afterInit and then scrollViewPortTo works. Can mark as closed.

Great. I’m glad to see this solved.