wikiti / jquery-paginate

A simple pagination plugin for html tables.
MIT License
14 stars 16 forks source link

Question, is there a way to limit the number of pages in the page numbers selection #1

Closed liranp1 closed 6 years ago

liranp1 commented 6 years ago

i have a table with more then 1000 rows. i limit the results to 15 result per page. but in the pages numbers i see 1-70 that is allot, is there a way to display only few and add ' ...' so user will know there is more?

EFinish commented 6 years ago

Look at https://github.com/wikiti/jquery-paginate#advanced-options at the 'limit' option. The example right below it uses limit to only show 10 results per page.

khe817 commented 6 years ago

@EFinish That did not answer @liranp1 's question. I have the same question as @liranp1 too.

I did a small trick for displaying page numbers within the n+-3 range of current select page:


$(document).ready(function() {
    $('#acc-invoice-list').paginate({
        limit: 10,
        onCreate: function(obj) {prettyPagination(3);},
        onSelect: function(obj, i) {prettyPagination(i+1);}
    });

});

function prettyPagination(currentPageIndex) {
    $('.page-navigation a').css('display', 'none');
    $('.page-navigation a').slice((currentPageIndex-3) <0 ? 0 : currentPageIndex-2, currentPageIndex).css('display', 'inline-block');
    $('.page-navigation a').slice(currentPageIndex, currentPageIndex+4).css('display', 'inline-block');
    // always display previous & next navigations
    $('.page-navigation a').slice(0, 2).css('display', 'inline-block');
    $('.page-navigation a').slice(-3, -1).css('display', 'inline-block');
    $('.page-navigation a').last().css('display', 'inline-block');
}
EFinish commented 6 years ago

@khe817 I am mistaken. Thank you for correcting me.

liranp1 commented 6 years ago

thank you all for your help! i works amazing

wikiti commented 6 years ago

Hey all!

Please, take a look at this comment.

Best regards, Daniel