How can I change the style of column header while using the export feature?

How can I change the style of column header while using the export feature?

java977java977 Posts: 7Questions: 3Answers: 0

Hi Allan,
Hope you are doing good.
I was looking into the datatable export feature and I want to change the style of column header.
I have some hidden text in the column header and while exporting it is also coming in the exported file, which I dont want.
Is there anyway I can control the style of the column header?
Please let me know.
Any help would be appreciated.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 62,301Questions: 1Answers: 10,216 Site admin
    Answer ✓

    There is no option for that at the moment I'm afraid. That is something i hope to address in future.

    Allan

  • java977java977 Posts: 7Questions: 3Answers: 0

    Thank you for letting me know.
    I was looking into exportOptions and trying to manipulate if I can hide the styles.
    So based on the current feature, whatever text is in the table will be read without exception.
    Thanks for the good work. I really like this feature.

  • java977java977 Posts: 7Questions: 3Answers: 0

    Hi Allan, just wondering if you got some chance to work on this.

  • allanallan Posts: 62,301Questions: 1Answers: 10,216 Site admin

    So there isn't a built in option for this yet (that will require the next major version of DataTables), but there is now a relatively simple option for doing it with the nightly version of Buttons.

    This example shows how a body function can be used to format body cells. There is also a header function that can be used to format header cells, and more importantly, it now passed in the header cell node. So you can read the data you want from the cell itself (using whatever DOM / jQuery methods you choose) and then return that value, which will be used for the header in the exported data.

    So slightly convoluted, but it is at least now possible.

    Allan

This discussion has been closed.