javascript - How to hide page numbers when records are less -


i using datatables pagination.when there more 5 records want show next,previous buttons , show number of pages drop down.

for using this

if($("#example").find("tr:not(.ui-widget-header)").length<=10){             console.log('hi');             $('#example_length').addclass('hide');             $('#example_paginate').addclass('hide');          }     } 

enter link description here lets there 5 records there no need show next or previous buttons neither number of records per page.

so hiding , works well.but problem if there 12 records on 1st page shows 10 records , next,previuos buttons visible , when click next button shows 2 records , here buttons disappear.

now user can not see 1-10 records there no button that

so how overcome issue.

how can disable buttons if total number of records less 10

here fiddle

in datatables api there page function returns current page number. change if statement check if it's not on page 1 also, so:

if($("#example").find("tr:not(.ui-widget-header)").length<=10 && this.page() > 1) 

Comments

Popular posts from this blog

c++ - QTextObjectInterface with Qml TextEdit (QQuickTextEdit) -

xcode - Swift Playground - Files are not readable -

jboss7.x - JBoss AS 7.3 vs 7.4 and differences -