DataTables logo DataTables

aLengthMenu not working in 1.9
  • I'm overriding DataTables defaults like this:

        $.extend( true, $.fn.dataTable.defaults, {
            "bDestroy": true,
            "bAutoWidth": false,
            "iDisplayLength": 100,
            "aLengthMenu": [[100, 200, 500, 1000], [100, 200, 500, 1000]],
            "sPaginationType": 'bootstrap'
        });
    

    But then the item length dropdown includes these options:

    100,200,500,-1
    100,200,500,All
    200
    100

    Obviously the first two make no sense.
  • Hi,

    You don't want it doing a deep copy here (the first parameter given to 'extend') since it will combine your array with the DataTables default array, thus causing the problem. If you just drop the true it will work okay: http://live.datatables.net/axirac/edit .

    If you do need to do a deep copy in future, then you would need to do something like this:

    $.extend( true, $.fn.dataTable.defaults, {
        "bDestroy": true,
        "bAutoWidth": false,
        "iDisplayLength": 100,
        "sPaginationType": 'bootstrap'
    });
    
    $.fn.dataTable.defaults.aLengthMenu = [[100, 200, 500, 1000], [100, 200, 500, 1000]];
    

    Allan
This discussion has been closed.
All Discussions

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Support

Get useful and friendly help straight from the source.