Datatables if table is paginated?

Datatables if table is paginated?

parsonsparsonsparsonsparsons Posts: 24Questions: 7Answers: 0

Apologies if this is somewhere obvious but I definitely looked.

How would I check to see the boolean value of my table paging option?

IE

(if table.paging == true) {
do something
}

Thanks!

Answers

  • parsonsparsonsparsonsparsons Posts: 24Questions: 7Answers: 0

    Did some more searching, maybe this works but its not exactly what I want

    //only one page equals no pagination? Not always the case...
    if (table.page.info().pages === 1) {
    do stuff
    }

  • kthorngrenkthorngren Posts: 9,318Questions: 25Answers: 2,147

    Looks like the length property of page.info() is the one to use. It returns -1 if paging is turn off. It will also return -1 if paging is on but the pageLength is set to -1, effectively turning paging off. You can see this in this example:
    http://live.datatables.net/pojepiri/2/edit

    Comment out paging: false and uncomment pageLength: -1. Might be better ways to do this.

    You could use the settings() API to get the settings object. This is not recommended as the settings object may change from version to version.

    Kevin

  • parsonsparsonsparsonsparsons Posts: 24Questions: 7Answers: 0

    Thanks Kevin, I did compare with paging on / off and was getting the same value as -1. But that was with only one page, so I will use that as my condition, thanks again!

Sign In or Register to comment.