Print 11 by 17 using Datatables Plugin with Cell Colors

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
sarojthapa60
Forum Newbie
Posts: 8
Joined: Sun Sep 11, 2016 9:36 pm

Print 11 by 17 using Datatables Plugin with Cell Colors

Post by sarojthapa60 »

I have a Datatables using HTML (DOM) sourced data. I have 30 columns in my table. I have a print button, button when I print about 6 columns do not fit. Also, some cells have background colors. How can I customize this Print function so that I can print 11 by 17 preserving the background colors of the cells?
My script for Datatables:

Code: Select all

<script>
    $(document).ready(function() {
        $('#myTable').DataTable( {
            "order": [[0, "asc"]],

            "paging": false,
            "scrollCollapse": true,

            "columnDefs": [{
                "targets": [0],
                "visible": false,
                "searchable": false
            }],

            dom: 'Bfrtip',
            buttons:
            [

           {
                    extend: 'print',
                    text: 'Print',

                }
                ]

        } );
    } );
</script>
User avatar
Christopher
Site Administrator
Posts: 13592
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Print 11 by 17 using Datatables Plugin with Cell Colors

Post by Christopher »

Printing HTML is not very dependable. Many print drivers will not print background colors. If you know the specific printer, then you may be able to get it to work. Also, you may need to instruct the user to print in landscape.

An alternative would be to generate a PDF of the table and have the user print that.
(#10850)
Post Reply