Ajax + scroller + scrollY not working

Ajax + scroller + scrollY not working

sebastianbarthsebastianbarth Posts: 43Questions: 11Answers: 0
edited September 2023 in Free community support

Link to test case:
https://live.datatables.net/reyokava/3/edit?js,output

Description of problem:
The example uses scroller and server side rendering. How can we set the initially scroll position to a given one (say line/px 2000)?

Setting scrollTop after drawing the table (so when the table knows its size), is not a solution because, we would fire two ajax request, one for the first page and one after scrolling. This gives us a hell of a load time (ajax request already can take several seconds) and flickering of table between the two draws.

"displayStart: 1000" seems not to have the desired effect: Scroll position is not changed, just the page is rendered at that position. Seems incompatible.

This question has an accepted answers - jump to answer

Answers

  • glimpsed_chaosglimpsed_chaos Posts: 140Questions: 30Answers: 4
    Answer ✓

    Using scroller.toPosition() seems to work in your test case. Here is the updated: https://live.datatables.net/reyokava/5/edit

    It's a little janky with the timeout set to 1000. I set it to 0 and it appears a little smoother. Obviously it is waiting for that data generation.

    Hope that helps.

  • sebastianbarthsebastianbarth Posts: 43Questions: 11Answers: 0

    I could not get it to work with the scroller.toPosition() before first page load.
    Instead I am now using the state load callback which are called before fetching the body data via AJAX.

Sign In or Register to comment.