$("#Table1").dataTable( {
dom: 'lBfr<"table-scrollable"t>ip',
stateSave: true,
lengthMenu: [[5, 10, 20, 50, -1], [5, 10, 20, 50, 'ALL']],
buttons: [
{
extend: "colvis",
className: '',
enabled: true
},
{
extend: 'pdfHtml5',
text: ' PDF',
titleAttr: 'PDF',
pageSize: 'A4',
// title: 'Export',
exportOptions: {
// modifier: { page: 'current' }
modifier: {
//page: 'current',
alignment: 'center',
},
columns: [0, 1, 2, 3, 4, 5, 6],
search: 'applied',
order: 'applied'
},
customize: function ( doc ) {
var logo1 = $('.img-fluid').attr("src");
//alert(logo1);
var logo = '';
//alert(logo);
//doc.pageMargins = [20,60,20,30];
doc.styles.tableHeader.fontSize = 9;
doc.defaultStyle.fontSize = 9;
doc.content.splice( 0, 1);
var now = new Date();
var jsDate = now.toGMTString();
doc['header']=(function() {
return {
columns: [
{
alignment: 'left',
italics: true,
text: '',
fontSize: 18,
margin: [10,0]
},
{
image: logo,
width: 350,
margin: [10,0]
},
{
alignment: 'right',
fontSize: 14,
text: ''
}
],
margin: [10, 0]
}
});
doc['footer']=(function(page, pages) {
return {
columns: [
{
alignment: 'left',
fontSize: '7',
text: ['Report Gen date: ', {
text: jsDate
}]
},
{
alignment: 'center',
fontSize: '7',
text: ['page ', {
text: page.toString()
}]
},
{
alignment: 'right',
fontSize: '7',
text: ['ReportID: ', {
text: 'NEOF0758'
}]
}
],
margin: [10, 0]
}
});
var objLayout = {};
objLayout['hLineWidth'] = function(i) { return .5; };
objLayout['vLineWidth'] = function(i) { return .5; };
objLayout['hLineColor'] = function(i) { return '#aaa'; };
objLayout['vLineColor'] = function(i) { return '#aaa'; };
objLayout['paddingLeft'] = function(i) { return 4; };
objLayout['paddingRight'] = function(i) { return 4; };
doc.content[0].layout = objLayout;
doc.styles.title = {
display: 'none',
fontSize: '0',
color: '#FFFFFF;'
}
// doc.content.splice( 1, 0,
// {
// margin: [ 0, 0, 0, 12 ],
// alignment: 'center',
// image: '',
// width: 500
// },
// );
}
},
{
extend: 'excelHtml5',
text: ' Excel',
titleAttr: 'Excel',
// title: 'Export',
customize: function (xlsx) {
var sheet = xlsx.xl.worksheets['sheet1.xml'];
// $('row:first c', sheet).attr('s', '5');
},
exportOptions: {
// modifier: { page: 'current' }
columns: [0, 1, 2, 3, 4, 5, 6]
}
},
{
extend: 'csvHtml5',
text: ' CSV',
titleAttr: 'CSV',
exportOptions: {
// modifier: { page: 'current' }
//
columns: [0, 1, 2, 3, 4, 5, 6]
}
}
],
select: true,
columnDefs:[
{orderable:false,targets:7}
],
} );