I have a table that I don't want to be ordered and I need all rows to be shown on the page. but for some reason neither order option nor pageLength aren't working. Table keeps getting ordered by the first column, and length options are still 5 - 10 (selected by default) - 25 and 50.
Here's my code:
var tableReport = $('#table-report-report').DataTable();
new $.fn.dataTable.Buttons(tableReport, {
order: [],
pageLength: 100,
lengthMenu: [ [100], ["All"] ],
buttons: [
'pageLength',
{
extend: 'excelHtml5',
text: '<i class="fa fa-file-excel-o"></i>',
titleAttr: 'Excel'
}
]
}).container().appendTo($('#buttons-report-report'));
I tried to alter it according to the documentary , like it's done in the pageLength example, but it still isn't working. I tried this code :
var tableReport = $('#table-report-report').DataTable();
new $.fn.dataTable.Buttons(tableReport, {
dom: 'Bfrtip',
lengthMenu: [
[ 10, 25, 50, -1 ],
[ '10 rows', '25 rows', '50 rows', 'Show all' ]
],
buttons: [
'pageLength'
]
}).container().appendTo($('#buttons-report-report'));
With this code it still offers me the same 5-10 (chosen by default) - 25 - 50 options.
I don't want to have table ordered. But even tho I asked not to order with order : [], it's still ordered by first column values. I also tried order : false, doesn't change anything.
I don't know how to fix it, so can please anyone help me? Excel export button is working properly tho.
Try like this
$(document).ready(function() {
$('#table-report-report').DataTable( {
"ordering": false,
lengthMenu: [
[ 10, 25, 50, -1 ],
[ '10 rows', '25 rows', '50 rows', 'Show all' ]
],
buttons: [
'pageLength'
]
} );
} );