DataTable: Hide the Show Entries dropdown but keep

2019-03-07 22:55发布

Is it possible to hide the Show Entries dropdown but keep the Search box in DataTable? I want to always display 10 rows with pagination at the bottom along with search box but do not want to display the Show entries dropdown.

标签: datatable dt
12条回答
SAY GOODBYE
2楼-- · 2019-03-07 23:14

For DataTables <=1.9, @perpo's answer

$('#example').dataTable({
    "bLengthChange": false
});

works fine, but for 1.10+ try this:

$('#example').dataTable({
    "dom": 'ftipr'
}); 

where we have left out l the "length changing input control"

1.9 Docs

1.10 Docs

查看更多
Luminary・发光体
3楼-- · 2019-03-07 23:19

Add this option:

"bInfo": false
查看更多
【Aperson】
4楼-- · 2019-03-07 23:22

If using Datatable > 1.1.0 then lengthChange option is what you need as below :

$('#example').dataTable( {
  "lengthChange": false
});
查看更多
啃猪蹄的小仙女
5楼-- · 2019-03-07 23:24

sDom: "Tfrtip" or via a callback:

"fnHeaderCallback": function(){
    $('#YOURTABLENAME-table_length').hide();
}
查看更多
萌系小妹纸
6楼-- · 2019-03-07 23:27

This is key answer to this post "bLengthChange": false, will hide the Entries Dropdown

查看更多
我欲成王,谁敢阻挡
7楼-- · 2019-03-07 23:27

To disable the "Show Entries" label, use "bInfo", example: "bFilter" is the search component, but are active by default.

$(document).ready( function () {
  $('#example').dataTable( {
    "bInfo": false
  } );
} );

Enable or disable the table information display. This shows information about the data that is currently visible on the page, including information about filtered data if that action is being performed.

查看更多
登录 后发表回答