Exclude Filter Dropdown values from excel export.
Exclude Filter Dropdown values from excel export.

I'm using code, see below, to add filter drop downs to my datatable. It works great and does exactly what I want. Unfortunately, when I export to excel my top row contains both the column header AND every value that is in the drop down. I have seen how to exclude columns in the documentation and how to include rows, but not how to exclude a row. Any help will be greatly appreciated. Thanks!
//this code creates the filter drop downs above each table column
"initComplete": function () {
var counter = 0;
this.api().columns().every( function () {
var column = this;
if (counter !=0)
{
var select = $('<br /><select style="width:75px; text-align:left;"><option value=""></option></select>').appendTo( $(column.header()) ).on( 'change', function () {
var val = $.fn.dataTable.util.escapeRegex(
$(this).val()
);
column
.search( val ? '^'+val+'$' : '', true, false )
.draw();
} );
column.data().unique().sort().each( function ( d, j ) {
//Column sorting Date formatting logic.
//if you change the colum ordering you have to chage these 0 based column numbers to reflect which ones are Due and Start Date
if (counter == 5 || counter == 9)
{
if (d != null)
{
var dateFormat = d;
dateFormat = $.datepicker.formatDate('mm/dd/yy', new Date(dateFormat));
d = dateFormat;
}
}
if (d != null)
{
select.append( '<option value="'+d+'">'+d+'</option>' );
}
} );
}
counter++;
} );
},
Replies
This was answered by this post...
http://datatables.net/forums/discussion/32097/pdf-export-not-working#latest