从Jquery数据表中隐藏LengthMenu

Sol*_*nde 24 javascript jquery jquery-datatables

请问如何从我的Jquery数据表中隐藏LengthMenu(显示每页显示的记录数的下拉列表)?

目前我可以禁用它,但我不希望它出现.请看 下面的小提琴: -

testdata = [{"id":"58","country_code":"UK"},{"id":"59","country_code":"US"}];
$('#test').dataTable({
    "aaData": testdata,
    "aoColumns": [
        { "mDataProp": "id" },
        { "mDataProp": "country_code" }
    ],
    "bLengthMenu" : false, //thought this line could hide the LengthMenu
    "bInfo":false,    
});
`//the next 2 lines disables the LengthMenu
//var aLengthMenu = $('select[name=test_length]');
//$(aLengthMenu).prop('display', 'disabled');
Run Code Online (Sandbox Code Playgroud)

Sri*_*r R 46

试试吧

$('#test').dataTable({
    "aaData": testdata,
    "aoColumns": [
        { "mDataProp": "id" },
        { "mDataProp": "country_code" },
        { "mDataProp": "title" },
        { "mDataProp": "pubdate" },
        { "mDataProp": "url" }
    ],
    "bLengthChange" : false, //thought this line could hide the LengthMenu
    "bInfo":false,    
});
Run Code Online (Sandbox Code Playgroud)

小提琴


hom*_*mtg 17

这样做:

"bLengthChange": false
Run Code Online (Sandbox Code Playgroud)

这将隐藏长度下拉列表.


Sha*_*tan 11

从 DataTables 1.10.18 开始,根据https://datatables.net/reference/option/lengthChange 这是隐藏 lengthMenu 的推荐方法:

$('#example').dataTable( { "lengthChange": false } );
Run Code Online (Sandbox Code Playgroud)

干杯


Gha*_*san 7

要完全禁用分页,请执行以下操作:

"paging": false
Run Code Online (Sandbox Code Playgroud)


小智 6

您可以通过禁用分页来执行此操作:

"bPaginate": false
Run Code Online (Sandbox Code Playgroud)