Display loading spinner under the button click event when the PDF export takes more than 10 seconds?

Display loading spinner under the button click event when the PDF export takes more than 10 seconds?

Venky1995Venky1995 Posts: 14Questions: 9Answers: 0

I am trying to make a PDf and I have implemented all the features that we required with great ease. The only question that I am struggling with at the moment is the button click event takes more than a few seconds to complete the PDF Export. Now I understand that this works under the button event handler. But how would I handle this event between the start and end of the export process.

Answers

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406
    edited January 2020

    I have got this to change the data tables defaults to make it show a font awesome spinner:

    $.extend( true, $.fn.dataTable.defaults, {
        "language": {
            "processing": "<span class='fa-stack fa-lg'>\n\
                                <i class='fa fa-spinner fa-spin fa-stack-2x fa-fw'></i>\n\
                           </span>&emsp;Processing ..."
        }
    } );
    

    This might work for your button as well if you turn on "processing":

    $.extend( true, $.fn.dataTable.defaults, { 
        processing: true
    } );
    

    You can also turn it on for your individual data table without changing the defaults.

    If this doesn't work - and it might not - you would need to use something like "busyLoad". And find the suitable data tables events in the docs in order to use it ... Like in here:

    .on('select', function () {
        // show
        $.busyLoadFull("show", { 
            fontawesome: "fa fa-spinner fa-spin fa-3x fa-fw"
        });
    ......
    .on('draw', function () {
         // hide
        $.busyLoadFull("hide", { 
          // options here 
        });
    

    This code shows a fuill screen spinner when the user selects a record and it hides the full screen spinner as soon as the drawing of the page has been completed.
    https://piccard21.github.io/busy-load/

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

    This thread might also help,

    Colin

  • apattersapatters Posts: 1Questions: 0Answers: 0

    The piccard21 samples do not work in IE, only Chrome.

  • rf1234rf1234 Posts: 2,808Questions: 85Answers: 406

    Just checked it with IE. Works fine! But maybe this is due to me using a polyfill which I strongly recommend to avoid trouble with IE.

    This one is really good:
    https://datatables.net/forums/discussion/comment/164504#Comment_164504

This discussion has been closed.