Print Button hides rows (for one table instance)
I have several datatables that are populated via server-side pagination.
For some reason, the Print functionality for one of the tables only prints the column headers.
The code I'm using to define the print button:
{
extend: 'print',
text: '<button type="button" title="Print button to print only this table" class="btn btn-default"><image class="toolbar-icon" alt="Print icon" src="assets/img/print.png"/><BR>Print</button>',
exportOptions: {
format: {
body: function ( dataHtml ) {
console.log(dataHtml);
// Grab displayed text
return $('<div>'+dataHtml+'</div>').text().trim();
}
}
}
},
I added the console.log to check what was being outputed, but it never reaches the code.
Any suggestions on how to debug this specific issue?
Does it work if you have only one table?
No, it doesn't - I tried removing any other Datatables on the page and I get the same result. Also, I have other pages with multiple datatables where I don't see this behavior.
This specific table appears on several pages (print fails for all) as it is implemented through a directive. I've looked over the code though and can't find anything different from other datatables for which the print works.
I think I found the issue after testing some more on pages with interactive tables - The print only works with what the page (that is, the angular state controller) was initially loaded with.
If the table values change and are reloaded through server-side calls, for instance with interactive tables, the print displays the table's initial values.
I think that with the directive I'm using, I have to make two server side calls because the value needed to make the proper call is loaded through ajax, so the table initializes with no values.
Is there a way to fix this (Update the print on datatables with server-side paging to use the current values rather than the initial ones)?
Closing as issue is too old and the version is no longer maintained.