Sollution for print image in your tables.

Sollution for print image in your tables.

PortinelliPortinelli Posts: 1Questions: 1Answers: 0
edited June 2018 in Free community support

Hi guys.

This easy and simple method to print images in tables.

Just change this code in your datatable.js

            }
            // Inject the table and other surrounding information
                    win.document.body.innerHTML =
                        '<h1>'+exportInfo.title+'</h1>'+
                        '<div>'+(exportInfo.messageTop || '')+'</div>'+
                        html+
                        '<div>'+(exportInfo.messageBottom || '')+'</div>';

                    $(win.document.body).addClass('dt-print-view');

                    $('img', win.document.body).each( function ( i, img ) {
                        img.setAttribute( 'src', _relToAbs( img.getAttribute('src') ) );
                    } );

                    if ( config.customize ) {
                        config.customize( win );
                    }

TO

                }
                // Inject the table and other surrounding information
                         var pageTitle = 'Page Title',
                                        stylesheet = '',
                                        win = window.open('', '', 'width=800,height=600');
                                    win.document.write('<html><head><title>' + pageTitle + '</title>' +

                                        '</head><body>' + $('.table')[0].outerHTML + '</body></html>');
                                        win.document.close();

                        // Allow stylesheets time to load

_
thats all. so funny.

Answers

  • hadi_du84hadi_du84 Posts: 1Questions: 0Answers: 0
    edited February 2020

    The easy and simple method to print images in tables-

            $(document).ready(function () {
                    $('#list-member3').DataTable({
                        dom: 'Bfrtip',
                        buttons: [
                            {
                                extend: 'print',
                                exportOptions: {
                                    stripHtml : false,
                                    columns: [0, 1, 2, 3, 4, 5, 6, 7, 8]  
                                    //specify which column you want to print
    
                                }
                            }
    
                        ]
                    });
    
                });
    
This discussion has been closed.