EDIT: This only happens when I'm using sScrollX. -- http://jsfiddle.net/4n3Hp/ -- Unfortunately, it's needed for this particular use case.
As tabletools doesn't work for me, due to its use of flash and some suboptimal behaviors for my situation, i'm trying to write an excel export. I've extracted all of the necessary cell information, but DataTables is doing something weird with the header.
Assuming a div of listTable (which is generic, but works for an example) I've tried
$('#listTable').dataTable().fnSettings().nTable.getElementsByTagName('thead')
which gets me the table header row, except it's been changed.
<th class="sorting" role="columnheader" tabindex="0"
aria-controls="listTable" rowspan="1" colspan="1"
style="width: 130px; padding-top: 0px; padding-bottom: 0px;
border-top-width: 0px; border-bottom-width: 0px; height: 0px;"
aria-label="Email Recipients: activate to sort column ascending"></th>
Which would be fine, except the original header text has been removed, the exact thing I need.
Looking at the DOM, it shows there being two actual tables, one of which has the cell data, and a new one encapsulated with a "datatables_scrollHeadInner" classed div. (If I have multiple tables on a page, this is problematic when providing a general solution.)
While I think I have a hackaround solution (pull from the aria-label and separate by colon, and never use a colon in a header; or do some awkward jquery navigation), I'd like to know how I can more elegantly extract the headers from a dataTable.