How can I exclude certain column and row while exporting from DataTables using TableTools.
| id | data | date | Status |
|----|-----------|----------------|--------|
| 1 | some data | october 2014 | ok |
| 2 | some data | september 2014 | |
I want to hide the status column and the row which doesn't have status as "ok". Any tips to solve this problem would be appreciated.
There is as far as I know not a "magic" option that solve both problems. And the options to solve each issue seems to exclude each other (would be nice if anyone can disprove that). But I have found a solution (to avoid redundant code I only show it for the copy button) :
Explanation :
mColumns : [0, 1, 2]-> export only theid,dataanddatecolumnsfnInit-> be able to do something with the button when it is initialized$(nButton).on('mousedown', function() {-> filter rows where status is "ok"$(nButton).on('mouseup', function() {-> unset the "ok" filter when the export is doneoSelectorOpts : { filter: 'applied', order: 'current' }-> set tabletools to only export filtered rows in the order they appear for the user.The reason for using
mousedown/mouseupis that the above does not work withclickor the button functionfnComplete.Add this functionality to all your buttons, eg
xls,csv,pdfandprint. I think there is a problem with theprintbutton. As far as I know, it earlier had "problems" by following the button-instructions. Dont know if this has been fixed recently.