Custom html-template for printing a single row?
Custom html-template for printing a single row?
I want to print a single row of a datatable in a specific layout, not simply as a table/row. Is it possible to call a custom html-file as a template to insert the data I want to print? for example, I'd like to print a serial letter for each row (=person) in my datatable where most of the text is equal but the name and address should be inserted from my datatable? Is something like this possible?
regards, martin
This question has accepted answers - jump to:
This discussion has been closed.
Answers
HI Martin,
If you want to do it all client-side, use the
data().row()
method to get the data for a specific row. Then you can put it into whatever template you want and use that for the print view.If you wanted the server to create the HTML page to print, then have a link in your DataTable which will take the user to the print page with a query parameter giving the row id to print, so the server can get the data for that row and template it out. e.g.
print.php?row=7
.Regards,
Allan
I think Allan meant
row().data()
.Kevin
Hi Allan,
sorry for my late reply but I wanted to say 'thank you' for the answer. I didn't know the row().data() and had to find a solution very fast, so I managed to do it in another, intricately or circuitous way:
I created a button outside/above the datatable and a js-function that pulls the data from a selected row (tr td.each()...), posts the data to a php-page that writes the data into a session, then opens the print template (php) and write the session-data into the print template. This might be a little bit too complicated, but works fine for me.
Thanks you again, I really love datatables, but as a (german) newbie I partially find it hard to read through the extensive documentation.
Regards, martin