Header row is not printing using print button ?
Header row is not printing using print button ?

Hi I am using print button with header row column search. my code is working good but header row not going in print it is not going in pdf too. This is the example jsfiddle link
here is my js code ( Please Help me to find out where i did mistake)
$(document).ready( function () { // Setup - add a text input to each footer cell $('#ContentPlaceHolder1_GridView1 thead tr').clone(true).appendTo( '#ContentPlaceHolder1_GridView1 thead' ); $('#ContentPlaceHolder1_GridView1 thead tr:eq(1) th').each( function (i) { var title = $(this).text(); $(this).html( '' ); $( 'input', this ).on( 'keyup change', function () { if ( table.column(i).search() !== this.value ) { table .column(i) .search( this.value ) .draw(); } } ); } ); var table = $('#ContentPlaceHolder1_GridView1').DataTable({ dom: 'Bfrtip', buttons: [ { extend: 'print', title: '', customize: function ( win ) { $(win.document.body) .css( 'font-size', '10pt' ) .prepend( document.getElementById('ContentPlaceHolder1_lblCompanyNameHeader').innerText + 'Placement Register
'
);
$(win.document.body).find( 'table' )
.addClass( 'compact' )
.css( 'font-size', 'inherit' );
}
},
'excelHtml5',
'csvHtml5',
'pdfHtml5'
],
"paging": false
} );} );
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You need to apply the "complex headers" technique explained here:
https://datatables.net/release-datatables/examples/advanced_init/complex_header.html
This will also enable correct column sorting,which you currently don't have.
tangerine can u give me link of more clear example of Complex header with Column search.
You will want to use
orderCellsTop
. This will move the sorting listeners to the top row and I believe the top row will be exported instead of the second.Kevin
Thanks a lot "kthorngren" you are right OrderCellsTop is working for me. I heartily thanks full to you.