How to get the records that are currently visible on the table

How to get the records that are currently visible on the table

ThisBytes5ThisBytes5 Posts: 5Questions: 2Answers: 0

I have a table that currently only shows 5 rows of 50, no pagination as I'm using scrollY. How do I get what 5 Rows are currently being displayed?

I have a timer that is auto scrolling the table once record at a time, and I need to know when the last record has been displayed on the screen. Yes, I'm keeping count, but the scrolling takes longer than the timer takes to fire and scroll the records.

Any help would be appreciated

Answers

  • allanallan Posts: 49,501Questions: 1Answers: 7,286 Site admin

    Hi,

    I'm afraid there is no API for that in DataTables. You'd need to know the height of the rows and also get the scrollTop of the DataTables scrolling container. Then subtract the scrollTop from the height to get the top displayed row. Likewise for the last displayed row add the container's height.

    There is no API for this as it isn't something that DataTables itself needs to know. its just a scrolling viewport, so it isn't concerned about the position of the scroll, that's up to the end user, just the contents in the scrolling viewport.

    Allan

Sign In or Register to comment.