How to use Pace or processing bar when export as excel?

How to use Pace or processing bar when export as excel?

shi fengshi feng Posts: 1Questions: 0Answers: 0

I'm using server side for datatables and using ajax for exporting excel, and I try to use Pace when I export excel, but it seems when the excel was downloaded, the Pace.start() begin executed.
If I want to execute Pace.start() after click export button, what should I do?
The following are javascript for buttons:

buttons : [
                    {   
                        extend : 'excelHtml5',
                        className : 'btn default',
                        title : '{{reportlabel.labelname}}',
                        exportOptions: {
                            columns: {{exportcolumns}}
                        },
                        customizeData: function ( data ) {
                            /* if(data.body.length <= pagesize){
                                return data;
                            } */
                            Pace.start();
                             $.ajax({
                                url: "/report/{{rtype}}/{{reportid}}/exportexcel",
                                data: excelparameter,
                                async: false,
                                success: function(returnData) {
                                    data.body = returnData;
                                },
                                error:function (xhr, ajaxOptions, thrownError){
                                    console.log("export excel error")
                                }
                            });
                            Pace.stop();
                            return data;
                        }
                    }
                ]

Replies

  • allanallan Posts: 61,847Questions: 1Answers: 10,134 Site admin

    I would suggest using a custom button type instead of using the excelHtml5 button type. That way to can control it a little easier - specifically you'll need to call the action method of the excelHtml5 button type and then your Pace.stop() method once that has completed. The last example in the buttons.buttons.action documentation shows how that might be done.

    Allan

This discussion has been closed.