Category / Section
How to resolve the issue with exporting action link in v12.3?
1 min read
Problem
Issue with Export URL in version 12.3.0.36
Cause
The Exporting feature included in Volume 3, 2014 v12.3.0.36 has an issue with the URL link passed on by clicking the export icon in the toolbar.
Solution
This issue can be handled with the following workaround solution.
JS
<script type="text/javascript"> function toolbarClick(args) { args.cancel = true; switch (args.itemName) { case "Excel Export": this.export("/Home/ExportToExcel"); break; case "Word Export": this.export("/Home/ExportToWord"); break; case "PDF Export": this.export("/Home/ExportToPdf"); break; } } </script>
In the toolbarClick event, the default action of the Grid is prevented and the URL for the exporting operation is passed to the export() method explicitly. The URL path should be relative path.
MVC
@(Html.EJ().Grid<object>("Grid") .Datasource(((IEnumerable<object>)ViewBag.datasource .ToolbarSettings(toolbar => { toolbar.ShowToolbar().ToolbarItems(items => { items.AddTool(ToolBarItems.ExcelExport); items.AddTool(ToolBarItems.WordExport); items.AddTool(ToolBarItems.PdfExport); }); }) .AllowPaging() .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Add(); col.Field("CustomerID").HeaderText("Customer ID").Add(); col.Field("Freight").Format("{0:c}").Add(); col.Field("EmployeeID").HeaderText("Employee ID").TextAlign(TextAlign.Right).Add(); col.Field("OrderDate").Format("{0:MM/dd/yyyy}").Add(); col.Field("ShipCity").Add(); col.Field("ShipCountry").HeaderText("Ship Country").Add(); }) .ClientSideEvents(eve=>eve.ToolbarClick("toolbarClick")) )