Hide LengthMenu from Jquery datatable

Sola Oderinde picture Sola Oderinde · Nov 12, 2013 · Viewed 35.1k times · Source

Please how do I hide the LengthMenu (the dropdownlist that displays number of records being shown per page) from my Jquery datatable?

Currently I am able to disable it, but I do not want it to appear at all. See my Fiddle here below:-

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');

Answer

Sridhar R picture Sridhar R · Nov 12, 2013

Try with

$('#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,    
});

Fiddle