Vertical scroll detect on datatable with both horizontal and vertical scroll.

Vertical scroll detect on datatable with both horizontal and vertical scroll.

EvieEvie Posts: 7Questions: 2Answers: 0

My datatable has both horizontal and vertical scrolling. I would like to detect when I scroll down only but when I use the following:

$('div.dataTables_scrollBody').scroll( ... );

It also detects the scrolling horizontally. Can someone help me figure this out: I want to add a row to my datatable only when I scroll down. (not when i scroll up or scroll to the left or right.)

Thank you

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    Answer ✓

    Maybe one of the techniques in this SO thread will help.

    Kevin

  • EvieEvie Posts: 7Questions: 2Answers: 0

    Thank you Kevin for the quick response. The thread was helpful, but didnt completely solve the issue. I can now detect vertical scroll only.
    But how about if I want to detect if I am at the end of a vertical scroll?

  • kthorngrenkthorngren Posts: 21,341Questions: 26Answers: 4,954
    edited February 2023 Answer ✓

    This SO thread shows some options to determine when the end of the scroll window is reached. Combining techniques from both threads I built an example for you:
    https://live.datatables.net/penuceza/1/edit

    Use any of those or other standard jQuery/Javascript methods you wish to monitor the vertical scrolling of the table.

    Kevin

  • EvieEvie Posts: 7Questions: 2Answers: 0

    Thank you Kevin, this was really very helpful.

Sign In or Register to comment.