Save table to excel with header - in header are inputs
Save table to excel with header - in header are inputs
dandoo
Posts: 3Questions: 1Answers: 0
Hello,
I have a table where in header I have inputs to filtering and I would like also to use Save button to excel. Problem is that excel file have empty header in that case.
How to add header to excel maybe placeholder or name of input?
$('#itemsJS thead th').each( function () {
var title = $(this).text();
if (title != ''){
$(this).html( '<input type="text" name="'+title+'" class="form-control" placeholder="'+title+'" />' );
}
} );
$('#itemsJS').DataTable({
ordering: false,
scrollX: true,
dom: 'Bfrtip',
buttons: [
{
extend: 'excelHtml5',
text: 'Zapisz do Excel',
className: 'btn btn-success',
},
{
extend: 'pdfHtml5',
text: 'Zapisz do PDF',
className: 'btn btn-success',
orientation: 'landscape',
pageSize: 'LEGAL'
}
],
initComplete: function () {
// Apply the search
this.api().columns().every( function () {
var that = this;
$( 'input', this.header() ).on( 'keyup change clear', function () {
if ( that.search() !== this.value ) {
that
.search( this.value )
.draw();
}
} );
} );
}
});
This discussion has been closed.
Answers
We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.
Cheers,
Colin
link to test case: live.datatables.net/pamepixe/1/edit?html,css,js,output
OK, I found solution in older questions. I need to add header above inputs to search and enable option orderCellsTop.