How to get x-scroller & y-scoller's position?

How to get x-scroller & y-scoller's position?

ayrilamryayrilamry Posts: 2Questions: 1Answers: 0
edited April 3 in Free community support

Hi,

I have a simple datatables as below. The table can be scrolled vertically & horizontally.
When I click the button below, I want to get the current position of x-axis & y-axis of the scroller.
Is it possible?

Answers

  • allanallan Posts: 61,628Questions: 1Answers: 10,091 Site admin

    You could use the scrollTop and scrollLeft properties of the div.dt-scroll-body element. DataTables itself doesn't provide an API to get those properties, so you need to use jQuery or DOM methods (I suppose you could wrap that into a plugin API method if you want).

    Allan

  • ayrilamryayrilamry Posts: 2Questions: 1Answers: 0
    edited April 3

    @allan
    Thanks for the answer.
    When viewing the page, is it also possible to set scroll index to set initial scroll position with any Datatables API?

  • allanallan Posts: 61,628Questions: 1Answers: 10,091 Site admin

    No, sorry. That also would also require direct DOM interaction.

    Allan

Sign In or Register to comment.