customizeData

customizeData

RagnarGrootKoerkampRagnarGrootKoerkamp Posts: 48Questions: 14Answers: 1
edited July 2016 in Buttons

Currently, only the excel export has a customizeData option to modify the raw data object before the document is generated. It would be nice to have a similar function for the copy and csv exports.

In my case, I have a table where some cells contain nested DataTables, and I would like to create something like

col | col a | col b
-------------------------
v   | v1a   | v1b 
    | v2a   | v2b 

where the v[12][ab] values are a nested table in the first row. Would there be an easy way to achieve this without implementing customizeData mysql?

(I don't bother implementing customizeData. I'm just curious why it isn't there yet.)

I kind of expected this to be a member of exportOptions, so that all export types can use the same callback. Also, in the excel export, customizeData is directly called on the output of buttons.exportData(), so moving it inside that function seems more logical to me.

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,489Questions: 1Answers: 10,469 Site admin
    Answer ✓

    The customizeData option is a bit of a legacy hack. It was put in place before the Excel export buttons had a customize callback and it was the only way to modify the output data.

    Would there be an easy way to achieve this without implementing customizeData mysql?

    I'm not sure this would be easy even with customizeData. How would you represent a nested table in CSV for example?

    Allan

  • RagnarGrootKoerkampRagnarGrootKoerkamp Posts: 48Questions: 14Answers: 1

    I decided to implement the customData callback, and now, it returns something like:

    "1" "Question 1"    "1" "Answer 1 to question 1"
    ""  ""              "2" "Answer 2 to question 1"
    ""  ""              "3" "Answer 3 to question 1"
    "2" "Question 1"    "1" "Answer 1 to question 2"
    ""  ""              "2" "Answer 2 to question 2"
    ""  ""              "3" "Answer 3 to question 2"
    

    which suits my purposes just fine.

This discussion has been closed.