jquery - DataTables numbers_length = 3 change pagination buttons -


by setting numbers_length property 3, able produced this

enter image description here

is there way can 3 page numbers (previous, current , next) :

enter image description here

solution

you can use our plug-in simple numbers - no ellipses.

$(document).ready(function() {    $('#example').datatable({       'pagingtype': 'simple_numbers_no_ellipses'    }); }); 

however plug-in shows "previous" , "next" buttons. overcome use modified code below.

$.fn.datatable.ext.pager.numbers_no_ellipses = function(page, pages){    var numbers = [];    var buttons = $.fn.datatable.ext.pager.numbers_length;    var half = math.floor( buttons / 2 );     var _range = function ( len, start ){       var end;        if ( typeof start === "undefined" ){          start = 0;          end = len;        } else {          end = start;          start = len;       }        var out = [];       ( var = start ; < end; i++ ){ out.push(i); }        return out;    };      if ( pages <= buttons ) {       numbers = _range( 0, pages );     } else if ( page <= half ) {       numbers = _range( 0, buttons);     } else if ( page >= pages - 1 - half ) {       numbers = _range( pages - buttons, pages );     } else {       numbers = _range( page - half, page + half + 1);    }     numbers.dt_el = 'span';     return [ numbers ]; };  $(document).ready(function (){       var table = $('#example').datatable({       pagingtype: 'numbers_no_ellipses'    }); }); 

see this jsfiddle code , demonstration.

links


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -