Dear all,
At the moment, I need a syntax that changes the base name of the CSV files that are downloaded.
I need that: When CSV's are downloaded, instead of a standardized name for all files, tell me the name of the distributor in question.
Example:
Let's say I have a dispatcher where there are several records inside a table called "patients". The moment I download that information from this table, my current code creates a CSV file with table name 1, 2, 3, 4 and so on.
If my distributor is SG459300, I want the downloaded table to be named SG459300.
What I have tried:
</script>
<!-- Datatable -->
<script type="text/javascript" src="../assets/js/datatables.min.js"></script>
<script src="../assets/js/table2csv.js"></script>
<script type="text/javascript">
function export2CSV(tableID)
{
var table = $("#"+tableID).DataTable();
table.page.len( -1 ).draw();
$("#"+tableID).table2csv();
}
$( ".datatable" ).each(function( index ) {
var orderCol = 0;
var orderOrd = 'asc';
if ($(this).attr('data-orderdtcol')) {
orderCol = $(this).data('orderdtcol');
}
if ($(this).attr('data-orderdtord')) {
orderOrd = $(this).data('orderdtord');
}
$(this).dataTable(
{
lengthMenu: [
[ 10, 25, 50, 100, -1 ],
[ '10', '25', '50', '100' , 'All' ]
],
responsive: true,
"order": [[ orderCol, orderOrd ]],
"stateSave": true,
"language": {
"url": "../Translations/<?=($_SESSION['user'] instanceof User)?$_SESSION['user']->getLang():'en_US';?>/LC_MESSAGES/datatable.json"
}
} );
});
</script>