Change the default number of rows to display on one “page”

后端 未结 5 664
梦谈多话
梦谈多话 2020-12-14 16:06

How can I specify the number of rows to display on a single \"page\" when using DataTables\'s pagination feature?

5条回答
  •  无人及你
    2020-12-14 16:33

    For DataTables version 1.10.5 and newer, as documented on the blog post announcing the integration of HTML5 data-* attributes, the number of rows to show per page can be specified via the source (HTML) table through the data-page-length attribute:

    
         ...
    

    For DataTables version 1.10 and newer, as documented at Reference > Options > pageLength, the number of rows to show per page can be specified via the pageLength attribute:

    $('#example').dataTable( {
        "pageLength": 50
    });
    

    For DataTables older than version 1.10, as documented at DataTables > Usage > Options > iDisplayLength, the number of rows to show per page can be specified via the iDisplayLength attribute:

    $('#example').dataTable( {
        "iDisplayLength": 50
    });
    

    My two cents: use the data-* approach. It allows you to construct one dataTable call (that you can use throughout your app) while providing the option to configure how each individual table behaves:

    
    
         ...
    
    ...

提交回复
热议问题