set pdf export message from json
set pdf export message from json
on my pdfexport, i am pulling together a list of data specific to an event.
rather than show the event name multiple times in the list, i would like to hide the column and either append the event name to the title of the pdf, or the message.
I have extracted the data I need and set it as a variable using initComplete, and am using this data to update the table caption in the dom
initComplete: function ( settings, json ) {
//mycaption = console.log(json.data[0].tblorderdetails.DetailName);
mycaption = json.data[0].tblorderdetails.DetailName;
$("caption").html(mycaption);
},
How can i use the value in the pdf export button to set the message, if I try the following it is undefined ?
{
extend: 'pdf',
message: ''+mycaption+'',
text: '<i class="fa fa-file-pdf-o" aria-hidden="true"></i> PDF',
pageSize: 'A4',
download: 'open',
orientation: 'landscape',
exportOptions: {
columns: [1,2,4,5,6,7,8]
}
}
This question has an accepted answers - jump to answer
Answers
Hi,
Currently there isn't a method for doing this but Tom is looking into it and will get back to you.
Allan
cool, thanks
Hi
I've updated the
message
option for both flash and html5 versions of the PDF buttons. It should now allow a function to be passed in as well as a static string.You can download the nightly build of buttons that will have the updated code in it from here- https://datatables.net/download/nightly#Buttons
This will allow you to pass in your json, for example-
Hope this help, if you have any more questions let me know
Thanks
Tom
Downloaded the nightly build and updated the message, but get the following error...
pdfmake.js:16062 Uncaught TypeError: Cannot read property 'text' of undefined
if i replace the return value with a string., i also get the error
i also tried adding a button action, which works, so I guess my syntax is ok
Could you post your button code that is giving you the error?
vanilla page here
http://test3.forthwebsolutions.com/vanilla_ticketsales.php?EventID=126
(the nightly build js is uploaded, but resides in the 1.2.1 folder)
Apologies think I might of linked you to the wrong place as it seems buttons.html5.js you are using on that page is an older version without the updated code for the message option
Try using this nightly file as it should include the updated code.
https://nightly.datatables.net/buttons/js/buttons.html5.js
Thanks
Tom
Sorted !
Thanks