I am using the DataTables Buttons for Print and CSV - how can I suppress a column
I am using the DataTables Buttons for Print and CSV - how can I suppress a column
My DataTables view contains a column with a user-interface feature (checkbox to select a row) but I'd like this column to be suppressed in a Print or Export-to-csv view.
I've tried code like this:
'''
dataTables_searchResults.columns( '.nonPrintingColumn' ).visible( false );
dataTables_searchResults.buttons.exportData( {
columns: ':visible'
});
dataTables_searchResults.columns.adjust().draw( false );
and like this:
'''
var columnObj = dataTables_searchResults.column (7);
columnObj.visible (false, true);
and then triggering the print function:
'''
$('#dataTables-buttons-holding-div div.dt-buttons a.buttons-print').click();
In some cases the column gets hidden on-screen; but it never gets hidden in the Print view or the CSV view
Here's my DataTables debug bookmarklet code: izavej
Answers
I got it to work the way I wanted, using:
'''
then, in the Print triggering function:
'''
var columnObj = dataTables_searchResults.column (7);
columnObj.visible (false, true);
Thanks for posting back. Good to hear you've got it working.
Allan