settings()[0]._iDisplayStart is NaN

settings()[0]._iDisplayStart is NaN

leelsleels Posts: 6Questions: 2Answers: 0

I'm upgrading datatables to the latest version from 1.10.3 to 1.10.20 . I have the following piece of code to get the page number when i'm clicking on the page number.

var pageNumber = Math.ceil(table.fnSettings()._iDisplayStart / table.fnSettings()._iDisplayLength);

I have 3 tabs(essentially 3 datatables). When I change the page on one tab - the other two tabs must switch to the same page for which the above code worked fine using fnPageChange.

When I tried with the new version _iDisplayStart is NaN.

var pageNumber = Math.ceil(table.settings()[0]._iDisplayStart / table.settings()[0]._iDisplayLength);

With the old version - I'm seeing values in this field. What's the issue in the new version?****

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769

    You will probably be better off using the page.info() API to get the page info.

    Kevin

  • leelsleels Posts: 6Questions: 2Answers: 0

    From page.info - I'm not sure how I can get the page number being clicked on. Say Im on page 1 and I click on page 3 - how would I get 3 from page.info()? this is the info i got
    end: 10
    length: 10
    page: 0
    pages: 4
    recordsDisplay: 35
    recordsTotal: 35
    serverSide: false
    start: 0

  • kthorngrenkthorngren Posts: 20,302Questions: 26Answers: 4,769
    Answer ✓

    Not sure exactly what you are doing but I would use the page event then get the page info. Take a look at the example in the page docs.

    Kevin

  • leelsleels Posts: 6Questions: 2Answers: 0

    Thank you! I wasn't thinking clearly. I used the page value to change the page number in the other tabs. It worked.

This discussion has been closed.