Altering exported table data
Altering exported table data
I was looking for a way to alter the table data before exporting it, also would need to be able to determine which column it is to edit.
For example, if im exporting a table with the columns Status and Children, I wanted to know how I can change the boolean value of the Status column from 0/1 to Single/Married, and leave the children column as it is.
I used these two columns as example, because they can both contain a 0 and a 1, but only one should be altered.
Other columns also have epoch timestamps that I would like to parse into human readable dates, using a jQuery function I created
I looked in: print
, pdf
, button()
, buttons.exportData()
and a few other reference pages.
The funny/annoying part is, im pretty sure ive done this before somehow, but I cant find my old code, and I couldnt find anything about it on the website, and nothing when I consulted the Google Gods..
Thanks!
This question has an accepted answers - jump to answer
Answers
The only thing I found that might be of some help, was this: https://www.datatables.net/extensions/tabletools/button_options
But the span at the top says its been retired, and I couldn't find anything new about it
After a lot of Googling, I found this thread, In which @allan states:
which seems like it might be what I need... Can I define a
columns.render
which will be used by theorthogonal
option of thebuttons.exportData()
, but not assign it to a column in the table for the initial display?Hi,
not tested but you can use your own names for nested object, but dont know how it works with the export button.
//Data Source
//Export
Cheers
Hannes
Do those go inside the
columnDefs
?Heres what ive got so far, I havent even tried to use it in the export buttons yet though.. just working on defining how to render them
Alrighty.. I think I got it...
Only part im stuck on now, is for the columnDef targets 0,2 (usernames), I want it to display a link, but export just text, when I print it, it displays the link URL right next to the text: http://d.pr/i/TtxO
Any way to get that so it just exports the username as text?
Edit: Looks like I was able to get this by setting the
stripHtml
totrue
Thanks @btree
Looks like everything else is OK though!