Hiding pagination when the table only has a single page when filtering

Hiding pagination when the table only has a single page when filtering

mleppalamleppala Posts: 8Questions: 2Answers: 0

Is there a way to hide the pagination controls when there is only one page that display after you filter the table with and filtering, like text search, column filter and page length?

Answers

  • mleppalamleppala Posts: 8Questions: 2Answers: 0

    This problem was solved, I was pointed to creating my own pagination plugin to not display the pagination when all rows are displayed. So for anyone that needs it see https://datatables.net/plug-ins/pagination/ for reference.

    On the return line just add 'pages === 1 ? '' : ', for example

    return pages === 1 ? '' : [ 'first', numbers, 'last' ];
    

    What do you think about adding this feature either set as Datatable parameter to not display the pagination when all the rows are displayed or as as static code as I have in the example?

  • jkshapirojkshapiro Posts: 1Questions: 0Answers: 0

    This should be default behaviour; it shouldn't require a plugin.

  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin

    Thanks for the feedback. Personally I find it useful for the pagination to explicitly state that there is only one page. However, you can modify the library to suit your needs (that's what open source is all about :)).

    Allan

This discussion has been closed.