简体   繁体   English

如何更改分页大小

[英]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默认值为 10,25,50,100 但我想将其更改为 15、30、50、全部

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如何将条目大小更改为 15、30、50 和所有

[...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只需使用 lengthMenu 配置来设置自定义页面大小

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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