0

It's a table with data imported by php. enter image description here 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.

Community
  • 1
  • 1
Cristian Muscalu
  • 9,007
  • 12
  • 44
  • 76
  • No surprise since `TableExport.js` export DOM nodes, not the content of a jQuery `dataTable`. Furthermore `TableExport.js` has nothing to do with `TableTools`, which is BTW deprecated long time ago. Look for `buttons` and `excelHtml5`. – davidkonrad May 17 '16 at 10:56
  • I stopped using TableExport.js and discovered DataTables has it's own export buttons. They will do for now. Thank you for advice. – Cristian Muscalu May 17 '16 at 12:03

0 Answers0