How to get text for each column header

How to get text for each column header

tvalentinetvalentine Posts: 3Questions: 0Answers: 0
edited May 2013 in General
How would I go about getting the text for each column header in an existing dataTable?
I have a bunch of dataTables that represent reports. I want to take those dataTables and send all the header text and data to the server, which then spits back an excel file for the user to download. I have everything working except getting the header text..

I tried something like this:
$("thead tr th", tableElement)

But I get back the "wrong" th elements... they don't have any innerText in them. The dataTable seems to be split into two HTML tables actually.. one for the header columns with sorting functionality, and then a second table that contains the data. (I have scrolling enabled, not sure if that's what the two tables are about). I end up getting the ths from the second table, what I want is the ones from the first which actually have innerText.

I had thought about just storing the header names before I create the tables, but I'd rather just have a generic solution that I can use anyplace whenever. Had also thought about starting the search with the div "_wrapper" element that contains both tables, and just select the first one.

Just wondering if there is a better way... maybe even an API function?

Thanks!
Tim
This discussion has been closed.