Documentation Question [Buttons]

Documentation Question [Buttons]

mrdanskmrdansk Posts: 5Questions: 2Answers: 0

Referencing the **pdfhtml5 ** documentation I see this section:

_customize null
A function that can be used to customise the PDFMake document definition object for the pdfHtml5 button. The document object is passed in as the first parameter to this function and should be manipulated as required. A return value is not expected or used.

Please refer to the PDFMake documentation for information on how to manipulate this object and the options available for the generated PDF.

As of Buttons 1.5.2 this function is passed three parameters:

  1. An object containing the PDFMake document structure.
  2. The button configuration object
  3. A DataTables API instance for the table the button belongs to._

I've highlighted where it says "As of Buttons 1.5.2" because I can only see Version 1.5.1 in the CDN listing as the latest version.

I have multiple tables being initiated by a class rather than unique ID's so they all share the same options. However I was trying to use the Table instance to work out which table I was referencing and add some additional content to the PDF/Excel Export. But without the DataTables API instance I am not sure how I can get that reference to the current table.

Any ideas?

Answers

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Sorry yes, I've pushed out that documentation too early. 1.5.2 isn't far away!

    At the moment you'll need to use the nightly version of Buttons to get access to that final parameter.

    Allan

  • mrdanskmrdansk Posts: 5Questions: 2Answers: 0

    Thanks for the update Allan, I will consider using the nightly version.

    I don't suppose you might be able to help with a follow up question?

    I opened a question on stackoverflow but it's related to this issue with buttons.

    https://stackoverflow.com/questions/49253998/datatables-exporting-pdf-excel-with-footnotes

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Perhaps using messageBottom of the pdfHtml5 type would be the way to do it? It can be used as a function, so you could get your foot note information and return it as the text to be displayed.

    Allan

  • mrdanskmrdansk Posts: 5Questions: 2Answers: 0

    I was intending on using messageBottom but I need to somehow loop through the unordered list <li> elements for the nearest PDF/Excel button clicked then generate a string to add to message bottom before exporting. I'm not entirely sure how I can do that. I then looked at the PDFMake route and appending it as extra content in the customize function, however I had the same issue with getting the parent table element.

  • allanallan Posts: 63,455Questions: 1Answers: 10,465 Site admin

    Yup - good point. The messageBottom function isn't passed in any information, so I'm not sure that there would be a way to get the nearest element by DOM element. You'd probably need to hard code it going that way.

    As you say, customize is the other option with the dt parameter being passed in to use the table().container() method to get the table container and then use jQuery to get the near by information required.

    Allan

This discussion has been closed.