aLengthMenu not working in 1.9
aLengthMenu not working in 1.9
kmiyashiro
Posts: 1Questions: 0Answers: 0
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.
[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.
This discussion has been closed.
Replies
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