How to hide the pagination if there's only

How to hide the pagination if there's only

loigeloige Posts: 2Questions: 0Answers: 0
edited June 2010 in General
Is there a way to show the pagination bar only if there's more than one page available?

Thanks in advance for the attention.

- Loige

Replies

  • iuliandumiuliandum Posts: 70Questions: 0Answers: 0
    See in
    http://datatables.net/forums/comments.php?DiscussionID=131&page=1#Item_18


    I use this:
    [code]
    "fnDrawCallback": function() {
    if (Math.ceil((oTable.fnSettings().fnRecordsDisplay()) / oTable.fnSettings()._iDisplayLength) > 1) {
    $('#example_paginate)[0].style.display = "block";
    } else {
    $('#example_paginate')[0].style.display = "none";
    }
    }
    [/code]
  • loigeloige Posts: 2Questions: 0Answers: 0
    I changed your code a little bit and it worked for me :)

    [code]
    "fnDrawCallback": function() {
    if (Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength) > 1) {
    $('.dataTables_paginate').css("display", "block");
    } else {
    $('.dataTables_paginate').css("display", "none");
    }
    }
    [/code]

    Thanks very much for the hint ;)
  • burntsausageburntsausage Posts: 9Questions: 0Answers: 0
    My variation which can be copied and pasted for any table regardless of how many are on the page.
    You may need to change the jQuery traverse for the paginateRow variable.


    [code]
    "fnDrawCallback": function() {
    var paginateRow = $(this).parent().prev().children('div.dataTables_paginate');
    var pageCount = Math.ceil((this.fnSettings().fnRecordsDisplay()) / this.fnSettings()._iDisplayLength);

    if (pageCount > 1) {
    paginateRow.css("display", "block");
    } else {
    paginateRow.css("display", "none");
    }
    }
    [/code]
  • allanallan Posts: 63,534Questions: 1Answers: 10,475 Site admin
    Nice update - thanks for posting your code :-). This is something that could even be wrapped up into a feature plug-in: http://datatables.net/blog/Creating_feature_plug-ins ;-)

    Allan
This discussion has been closed.