var counter = 0;
function staticVar()
{
if (staticVar.counter == undefined)
{
staticVar.counter = 1
}
else
{
staticVar.counter++
}
return staticVar.counter;
}
//Our table has horizontal and vertical scroll bars and the first columni.e, the serial number will be fixed when scrolling
$(document).ready(function() {
var download_file_counter= staticVar();
var table = $('#example').DataTable({
"aoColumnDefs": [{ "bSortable": false, "aTargets": [0] }],
scrollY: '40vh',
scrollX: '40vh',
paging: true,
pageLength: 20,
lengthMenu: [[10, 25, 50, -1], [10, 25, 50, "All"]],
dom: 'Bflrtip',
buttons: [{
extend: 'print',
exportOptions: {
columns: ':visible'
}
},
{
extend: 'colvis',
className: 'colvisButton'
},
{
extend: 'excelHtml5',
title: 'LicenseDetails_'+(++download_file_counter)+'_'+today,
text: 'Excel',
exportOptions: {
modifier: {
page: 'current'
}
}
}],
columnDefs: [{
targets: -1,
visible: false,
orderable: false
}],
order: [[ 1, 'asc' ]]
});
download_file_counter= makeCounter();
$('#start-date, #end-date').change(function () {
table.draw();
});
$('#start-date1, #end-date1').change(function () {
table.draw();
});
$('#start-date2, #end-date2').change(function () {
table.draw();
});
});
This is my javascript code I want to pass the counter variable to the filename on clicking of the excel button. The counter is not incrementing for onclick of that.