filename: need table id
filename: need table id
QUESTION: How could I grab the (this) table id when the PDF button is clicked?
(Everything else is working, except this filename.)
{
extend: "pdf",
text: "Save PDF",
filename: function(){
var d = new Date();
var n = d.getTime();
var tableID = "**_need table ID here_**";
return tableID + "_" + n;**
},
exportOptions: {
stripNewlines: false,
columns: [0,1,2,3]
}
}
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Hi @kdpowell ,
You can use the
settings()
- as in the example here.Cheers,
Colin
Hi @colin,
I tried it out... but I'm using a class and not an id (see below) because I have two tables on the screen. When I implemented the settings as depicted in the fiddle, it worked! It correctly used the id of the first table when I clicked the pdf button, HOWEVER when I clicked the button with the 2nd table, it was still using the id of the table of the first button for the filename .
The big question:
How could I do this if I am using a class (more than one table on screen) ?
as opposed to (using table id)...
Hi @kdpowell ,
Probably the best thing would be if you could tweak that fiddle so it looks like what you've got, that way we'll be looking/thinking about the same thing. Or if it's easier, link to your page instead,
Cheers,
Colin
@colin
Thank you for your attention to this so far
Here's a fiddle I've been fiddling with: my fiddle looking for solution
Hi @kdpowell ,
You're welcome, and here's a tidy fix for you. There's no way of doing it in the filename function, as there's nothing passed into it, so each table needs to be declared individually. However, this can be done tidily without code duplication as in this example here.
Hope that works for you,
Cheers,
Colin