customize "pagingType": "full_numbers" of v1.10.7 to have it like previous versions

customize "pagingType": "full_numbers" of v1.10.7 to have it like previous versions

debarshidebarshi Posts: 6Questions: 3Answers: 0
edited June 2015 in Free community support

Actually I want to get rid of the starting page number and the last page number from full_numbers pagination type.

Version used : jquery datatable 1.10.7

Suppose the table has 10 pages, need to display 5 page buttons at a time and pagination should be as follows.

Case 1 : When on Page1
Pagination : First Previous 1 2 3 4 5 Next Last

Case 2 : When on Page4
Pagination : First Previous 2 3 4 5 6 Next Last

Case 3 : Similarly when on Page on Page 5
Pagination : First Previous 3 4 5 6 7 Next Last

I want to customize the full_numbers pagination style to have pagination like this.

Thanks in advance :)

Answers

  • debarshidebarshi Posts: 6Questions: 3Answers: 0

    Need exactly the way we have in this link - http://www.sprymedia.co.uk/dataTables-1.4/example_alt_pagination.html

  • debarshidebarshi Posts: 6Questions: 3Answers: 0

    Not very generic, but this is what I did to achieve the same (the logic will fail if the pagination button count is changed)... I will update a generic version shortly.

    Finding a way to over ride the function with out altering the original library.

        function _numbers ( page, pages ) {
            var numbers = [],
                buttons = extPagination.numbers_length,
                half = Math.floor( buttons / 2 ),
                i = 1;
            if ( pages <= buttons ) {
                numbers = _range( 0, pages );
            }
            else if ( page < half ) {
                numbers = _range( 0, buttons-2 );
            }
            else if ( page > pages - 1 - half ) {
                numbers = _range( pages-(buttons-2), pages);
            }
            else {      
                numbers = _range( page-2, page+3);
            }
        
            numbers.DT_el = 'span';
            return numbers;
        }
    
This discussion has been closed.