简体   繁体   中英

How to change Pagination Size

i am trying to change pagination size of table

the default is 10,25,50,100 but i want to change it to 15, 30, 50, all

in my table i use pagination and search in footer here my code

<script type="text/javascript">
  $(document).ready(function() {
    // Setup - add a text input to each footer cell
    $('#example tfoot th').each( function () {
        var title = $(this).text();
        $(this).html( '<input type="text" placeholder="'+title+'" />' );
    } );

    // DataTable
    var table = $('#example').DataTable({
        initComplete: function () {
            // Apply the search
            this.api().columns().every( function () {
                var that = this;

                $( 'input', this.footer() ).on( 'keyup change clear', function () {
                    if ( that.search() !== this.value ) {
                        that
                            .search( this.value )
                            .draw();
                    }
                } );
            } );
        }
    });
  } );

  </script>

how to change the entries size by 15,30, 50, and all

[...Array(countPages).keys()].map(num => <button key={num}
className={page === num ? "selected" : ""}
 onClick={() => setPage(num)}>{num + 1}</button>)

just use lengthMenu configuration to set custom page sizes

var table = $("#example").DataTable({
    lengthMenu: [[15, 30, 50, 100], [15, 30, 50, 100]],
    initComplete: function () {
       ...
        } );
     });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM