angular-datatables icon indicating copy to clipboard operation
angular-datatables copied to clipboard

Print Button hides rows (for one table instance)

Open vinays84 opened this issue 10 years ago • 4 comments

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. chrome_2016-10-06_11-46-53 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?

vinays84 avatar Oct 06 '16 15:10 vinays84

Does it work if you have only one table?

l-lin avatar Oct 11 '16 07:10 l-lin

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.

vinays84 avatar Oct 11 '16 13:10 vinays84

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)?

vinays84 avatar Oct 11 '16 13:10 vinays84

Closing as issue is too old and the version is no longer maintained.

l-lin avatar Nov 25 '17 15:11 l-lin