We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

ejGrid Export to Excel Waiting popup

Hello,

I need to display waiting pop up during ejGrid Excel Export. Please let me know how this can be achieved.

Thanks

3 Replies

TS Thavasianand Sankaranarayanan Syncfusion Team September 22, 2016 06:39 AM UTC

Hi Arun Gandhi, 

We have used form submit action for exporting Grid and so full post will occur and it reloads the page While exporting the Grid. Without making full post, we are unable to download the exported Excel file. So it is not possible to have a waiting popup for the export action of Grid when using the default “export” method of the Grid. 

But we have achieved your requirement using Ajax call and localSave option of exporting. The localSave option can be enabled using one of the overload of the export method. Please refer to the below code example. 

<div id="Grid"></div> 
 
<script type="text/javascript"> 
    $(function () { 
        var data = @Html.Raw(Json.Encode(ViewBag.data)); 
        $("#Grid").ejGrid({ 
            dataSource: data, 
               . . . . . . .  
            toolbarClick: function(args) {  
                var url = null; 
                if (args.itemName == "Excel Export") { 
                    args.cancel = true; 
                    url = "/Home/ExportToExcel"; 
                } 
                    . . .  . . 
                if (args.itemName.indexOf("Export") != -1) { 
                    $("#Grid").ejWaitingPopup("show"); 
                    var model = $.extend(true, {}, this.model); 
                    if (this.ignoreOnExport) { 
                        for (var i = 0; i < this.ignoreOnExport.length; i++) 
                            delete model[this.ignoreOnExport[i]]; 
                    } 
                    $.ajax({ 
                        type: "POST", 
                        url: url, 
                        data: { GridModel: JSON.stringify(model) },//pass the grid model 
                        dataType: "json", 
                        success: function (response) { 
                            $("#Grid").ejWaitingPopup("hide"); 
                            alert("Grid Exported"); 
                        }, 
                        error: function (Result) { 
                            $("#Grid").ejWaitingPopup("hide"); 
                            alert("Error"); 
                        } 
                    }); 
                } 
            } 
        }); 
    }); 
</script> 
 
namespace Sample.Controllers 
{ 
    public partial class HomeController : Controller 
    {  
              . . . . . 
                   . . .  . 
        public ActionResult ExportToExcel(string GridModel) 
        { 
            GridProperties gridPropert = (GridProperties)Syncfusion.JavaScript.Utils.DeserializeToModel(typeof(GridProperties),GridModel); 
            ExcelExport exp = new ExcelExport(); 
            IEnumerable data = new NorthwindDataContext().OrdersViews.ToList(); 
            exp.Export(gridPropert, (IEnumerable)data, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-lime",true,Server.MapPath("/outPut")); 
            return Json(new List<string>(), JsonRequestBehavior.AllowGet); 
        } 
             . . . . . 
    }  
} 
 
 
We have also prepared a sample that can be downloaded from the following location. 


Regards, 
Thavasianand S. 



UN Unknown Syncfusion Team March 9, 2017 02:19 PM UTC

Any chance to have this without the localSave option? I think it's very important to give feddback to the customer while the file is exporting

Regards



FS Farveen Sulthana Thameeztheen Basha Syncfusion Team March 11, 2017 06:37 AM UTC

Hi Antonio, 

We doesnot have support to achieve your requirement “display waiting popup during ejGrid Excel Export” without localSave option. Please get back to us if you need any further assistance. 

Regards, 

Farveen sulthana T 


Loader.
Up arrow icon