Reputation: 2148
In Datatables while viewing in the browser we show n columns. When a user clicks generate excel (implemented using TableTools), I want to hide some unneeded columns.
How to hide columns at runtime?
Upvotes: 2
Views: 4826
Reputation: 5655
Hope this will help
$(document).ready( function () {
$('#example').dataTable( {
"sDom": 'T<"clear">lfrtip',
"oTableTools": {
"aButtons": [
{
"sExtends": "csv",
"sButtonText": "Special columns",
"mColumns": [ 0, 1, 4 ]
},
{
"sExtends": "csv",
"sButtonText": "Visible columns",
"mColumns": "visible"
}
]
}
} );
} );
check this link http://datatables.net/extras/tabletools/button_options#collection_options
Upvotes: 4
Reputation: 1614
Check out Allan's release of Table Tools 2. I believe it has a mColumns property that allows you to specify what columns will be visible on the export when it is clicked.
Upvotes: 1