It's a table with data imported by php.
using jQuery.DataTable library to display the table.
//Display Table
var oTable = $('#myTable').DataTable( {
stateSave: true,
"iDisplayLength": 10,
"lengthMenu": [[10, 50, 100, -1], [10, 50, 100, "All"]],
} );
using TableExport.js library to export the table to Excel.
$("table").tableExport({
headings: true,
footers: true,
formats: ["xlsx","xls", "csv", "txt"],
fileName: "id",
bootstrap: true,
position: "bottom",
ignoreRows: null,
ignoreCols: null,
ignoreCSS: ".tableexport-ignore"
});
The problem is, any sorting done has no effect over the Exported File. It will only export what it displays the 1-st time the table is loaded.
Among other things, i tried applying the best voted solution here: Jquery - DataTables [tableTools]: export only visible rows
<script>
$(document).ready(function() {
var table = $('#myTable').DataTable( {
"pagingType": "full_numbers",
"iDisplayLength": 10,
"dom": 'T<"clear">lfrtip',
"oTableTools": {
"aButtons": [
{'sExtends':'xls',
"oSelectorOpts": { filter: 'applied', order: 'current' },
},
]
},
});
});
</script>
, but with no effect.