Datatable Jquery Print Specific Elements

Asked

Viewed 116 times

0

How to print specific elements from outside the datatable?

Here’s a JSFIDDLE for example

I wish that when I hit the button PRINT, that one div below be printed also

<div id="PRINT_HERE_TOO" class="test">
   <h1>
      Print Here Too!
   </h1>
</div>

Am I clear? Thank you!

1 answer

1


I think this is what you want:

https://jsfiddle.net/ms85e7zo/3/

$(document).ready(function() {
    $('#example').DataTable( {
          dom: 'Bfrtip',
        buttons: [
            {
                extend: 'print',
                messageTop: $("#PRINT_HERE_TOO").html()
               }
        ]
    } );
  • Your solution is good, but this setting I believe has to be within the settings of the datatable, because if there is more than 1 page in this solution, the print does not come with all pages.

  • edited the answer

  • Shooow, perfect guy! Thank you!

  • Didn’t get css? The pink color didn’t come off when printing.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.