Datatable Print: How to hide page title from Print

Datatable Print: How to hide page title from Print

hitesh.maiskarhitesh.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

Answers

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin
    Answer ✓

    Set the title option for the print option to be an empty string.

    Allan

  • hitesh.maiskarhitesh.maiskar Posts: 11Questions: 3Answers: 0

    Thanks Allan..
    It's worked...!!!:)

  • hitesh.maiskarhitesh.maiskar Posts: 11Questions: 3Answers: 0

    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.

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin

    The example shows the print view for me every time. What browser and OS are you using?

    Allan

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    The example shows the print view for me every time.

    And for me (Firefox).

  • hitesh.maiskarhitesh.maiskar Posts: 11Questions: 3Answers: 0

    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.

  • SriRishithaSriRishitha Posts: 42Questions: 4Answers: 0

    i have also same issue

  • hitesh.maiskarhitesh.maiskar Posts: 11Questions: 3Answers: 0

    Can I have solution of above issue of not showing print dialog ??
    I am waiting for response..

  • HPBHPB Posts: 73Questions: 2Answers: 18
    edited October 2017

    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.

  • SriRishithaSriRishitha Posts: 42Questions: 4Answers: 0

    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);

  • allanallan Posts: 63,468Questions: 1Answers: 10,466 Site admin

    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

  • hitesh.maiskarhitesh.maiskar Posts: 11Questions: 3Answers: 0

    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.

This discussion has been closed.