Page 1 of 1

Print 11 by 17 using Datatables Plugin with Cell Colors

Posted: Wed Nov 02, 2016 3:21 pm
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>

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

Posted: Fri Nov 04, 2016 2:35 pm
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.