DataTable print function - How to hide or remove the title and set the filename?

时间:2017-11-13 06:40:19

标签: jquery datatables

How do I hide or remove the title from the page I print and set the filename when I save the file into PDF or xps?

$('#report').dataTable( {
  dom: 'Bfrtip',
  buttons: [{
    extend: 'print',
    title: 'I want to hide this but use it as my filename when I save it.'
  }]
});

2 个答案:

答案 0 :(得分:0)

('#report').dataTable( { dom: 'Bfrtip', buttons: [{ extend: 'print', title: 'Filename here.', customize: function ( win ) { $(win.document.body).children("h1:first").remove(); } }] });

答案 1 :(得分:0)

您可以使用下面的示例代码

$('#report').dataTable( {
  dom: 'Bfrtip',
  buttons: [{
    extend: 'print',
    title: ''
  },
{
    extend: 'pdf',
    title: 'your file name'
  },
  ]
});