Datatable print button does not load css on first click

Datatable print button does not load css on first click

webcrew24webcrew24 Posts: 1Questions: 1Answers: 0
edited May 2022 in Free community support

I am using datatable default print button, when I click to print datatable css do not apply , it takes 3-4 seconds to load , how can I initialize css before showing print window or how to add delay so that print window only open after css loaded

enter image description here

I have tried multiple things like settimeout

 $(".DTTT_Print").click( function() {  setTimeout(  function() {  }, 5000000); });

var buttonsTbl = $('#cause_tbl').DataTable({
    "bProcessing": true,
    "destroy": true,
    "autoWidth": false,
    "bPaginate": true,
    "iDisplayLength": parseInt(disp_length, 10),
    "lengthChange": true,
    ]
});

 var buttons = new $.fn.dataTable.Buttons(buttonsTbl, {
    buttons: [{
        extend: 'excelHtml5',
        text: '',
        exportOptions: {
            columns: [0, 2, 3]
        }
    }, {
        extend: 'print',
        text: '',
        exportOptions: {
            columns: [0, 2, 3]
        }
    }, ],
}).container().appendTo($('#buttons'));

Edited by Colin - Syntax highlighting. Details on how to highlight code using markdown can be found in this guide.

Answers

  • colincolin Posts: 15,143Questions: 1Answers: 2,586

    That shouldn't be an issue, so something funny is going on there. We're happy to take a look, but as per the forum rules, please link to a test case - a test case that replicates the issue will ensure you'll get a quick and accurate response. Information on how to create a test case (if you aren't able to link to the page you are working on) is available here.

    Cheers,

    Colin

Sign In or Register to comment.