Datatable Print: How to hide page title from Print
Datatable Print: How to hide page title from Print
hitesh.maiskar
Posts: 11Questions: 3Answers: 0
Hi,
I want to hide page title from print. How can I do that.
I have added my custom title as per code given below.
$(win.document.body).prepend(
'<span style="font-size: 15pt">All Transactions </span>'
);
Please see attached.
Thanks,
Hitesh.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Set the
title
option for theprint
option to be an empty string.Allan
Thanks Allan..
It's worked...!!!:)
One more question Allan,
Print button shows print preview first time only. From second time it shows data table in browser's new tab. For this, Clicking on previous tab and coming back to datatable page. Then after it shows print preview dialog.
I have enabled autoPrint = true, but still its not working.
This is reproduced on data table demo too..!!!:(
**https://datatables.net/extensions/buttons/examples/print/simple.html**
Thanks,
Hitesh.
The example shows the print view for me every time. What browser and OS are you using?
Allan
And for me (Firefox).
Alan,
Sorry for late reply..!!!
I am using Chrome Version 62, Wind 10
I am printing through external button by javascript.
/// external button click event
table.button('print:name').trigger();
Still its not opening print preview dialog at first attempt.
Your help would be highly appreciated.
Thanks,
Hitesh.
i have also same issue
Can I have solution of above issue of not showing print dialog ??
I am waiting for response..
I've created a small jsfiddle with an external print button and it works as expected. (Win 10, Chrome v61)
You're saying you're on Chrome Version 62, but that's not available (yet). I'm not sure if @allan is willing to give support for unreleased versions.
If this jsfiddle works for you, it's not a browser issue but something in your code.
If it doesn't you could contact the chromium dev team with this jsfiddle and file a bug report.
comment the settimeout in buttons.print.js,
it is working for me
//setTimeout(function () {
if (config.autoPrint) {
win.print(); // blocking - so close will not
win.close(); // execute until this is done
}
// }, 500);
That timeout is there to allow time for any images or CSS files to load before triggering the print.
Perhaps the workaround for the moment is to disable autoPrint and have the user press ctrl-p / cmd-p.
Allan
Hey HPB,
Thanks for your response...!!!
Your jsfiddle does not work in chrome v 62.
It previews print dialog first time but not next time again.
Thanks,
Hitesh.