aLengthMenu not working in 1.9

aLengthMenu not working in 1.9

kmiyashirokmiyashiro Posts: 1Questions: 0Answers: 0
edited February 2012 in DataTables 1.9
I'm overriding DataTables defaults like this:

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

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.

Replies

  • allanallan Posts: 63,692Questions: 1Answers: 10,500 Site admin
    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:

    [code]
    $.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]];
    [/code]

    Allan
This discussion has been closed.