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

Export Bug

Hi there,

I have been working on page which contains grid with custom template column at the end.  Today I tried to add the export functionality and I think I have stumble upon a bug (or I have done something wrong).  I have copy pasted the tail end of the chtml file below.  If I commend out the highlighted portion (i.e. custom template column) the export functionality is working otherwise when I click on the button the web page is redirected to  something like http://localhost:2530/ExportToExcel

col.Field("StatusName").HeaderText("Status").TextAlign(TextAlign.Right).Width(75).Add();
col.HeaderText("Manage Tasks").AllowFiltering(false).AllowEditing(false)
                    .Template(true).TemplateID("#columnTemplate")
                    .TextAlign(TextAlign.Center)
                    .Width(120).Add();
            }).ShowColumnChooser()
            .ClientSideEvents(eve => eve.Create("create")))
<br />
<div>
    @Html.ActionLink("Add New Project", "Add")
</div>

<script type="text/x-jsrender" id="columnTemplate">
    @*In the template column we can get the values of corresponding row.*@
    <a rel='nofollow' href='/ProjectTask/TaskList?projectId={{:ID}}'> Tasks</a> &nbsp;
    <a rel='nofollow' href='/ProjectTask/ProjectGantt?projectId={{:ID}}'> Ghantt</a> &nbsp;
    <a rel='nofollow' href='/Project/ProjectUsers?projectId={{:ID}}'> Resource</a>
</script>
<script type="text/x-jsrender" id="idColumnTemplate">
    @*In the template column we can get the values of corresponding row.*@
    <a rel='nofollow' href='/Project/Edit?Id={{:ID}}'> {{:ID}}</a> &nbsp;
</script>

<script>
    function create(args) {
        var index = $.inArray("dataSource", ej.Grid.prototype.ignoreOnExport);
        ej.Grid.prototype.ignoreOnExport.splice(index, 1);
    }
</script>

3 Replies

BM Balaji Marimuthu Syncfusion Team December 11, 2015 08:53 AM UTC

Hi Prasanthan,

Thanks for contacting Syncfusion support.

We have checked with the provided code example and the Exporting is not depend on the template column in Grid.

When we run the Grid/sample from the view page(ex: “/Home/Index”) the export action is redirected properly to the controller action “localhost:2530/Home/ExportToExcel”. But when run the Grid/sample from the controller page (ex: HomeController), export is redirected into the default route “localhost:2530/ExportToExcel” instead of controller action method.

To avoid this issue, we suggest you to use the Mappers in Grid. Refer to the sample and code example as below.
Sample: Exporting-Mappers

Help Document: http://help.syncfusion.com/aspnetmvc/grid/exporting



@(Html.EJ().Grid<OrdersView>("FlatGrid")

        .Datasource((IEnumerable<object>)ViewBag.datasource)

                .ToolbarSettings(toolBar => toolBar.ShowToolbar().ToolbarItems(items =>

                {

                    items.AddTool(ToolBarItems.ExcelExport);

                    items.AddTool(ToolBarItems.WordExport);

                    items.AddTool(ToolBarItems.PdfExport);

                }))

               .Mappers(map => map.ExportToExcelAction("/Home/ExportToExcel")

                  .ExportToPdfAction("/Home/ExportToPdf").ExportToWordAction("/Home/ExportToWord"))


            .AllowPaging()

        .Columns(col =>

        {

            col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add();

            col.Field("CustomerID").HeaderText("Customer ID").Width(80).Add();

           

            . . .

        }).ShowColumnChooser()
            .ClientSideEvents(eve => eve.Create("create")))



Still if you face the issue/ if we misunderstood your requirement could you please share the following details to find the cause of issue and provide you better solution at the earliest?

1.     Share Essential Studio version

2.     Share browser details.

3.     Revert us the attached sample.

Regards,
Balaji Marimuthu



PR Prasanth December 11, 2015 09:16 AM UTC

Hi Balaji,

Thanks a lot.  Your solution (using mapping) has solved my problem of redirecting.  I can now export into either Excel or PDF files.  I am assuming there won't be any issues if I deploy the solution to Azure environment (both WEB and SQL back-end).

However I have an error occurring if I am trying to export as a word document.  I am suspecting it could be something do with the local assemblies?  I am running Visual studio 2015 and using Syncfusion 13.3.0.7, C# 4.6.   I am happy with the ability to export into excel (and pdf) it will be nicer to have word working as well but not necessary thought I raise the issue with you

I have copy pasted the error message below.

System.ArgumentOutOfRangeException was unhandled by user code
  HResult=-2146233086
  Message=Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
  ParamName=index
  Source=mscorlib
  StackTrace:
       at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
       at System.Collections.Generic.List`1.System.Collections.IList.get_Item(Int32 index)
       at Syncfusion.DocIO.DLS.WCellCollection.get_Item(Int32 index)
       at Syncfusion.EJ.Export.GridWordExport.ExportRecordRow(String value, GridTableCellType style)
       at Syncfusion.EJ.Export.GridWordExport.ProcessColumnHeader(Column column)
       at Syncfusion.EJ.Export.GridWordExport.ProcessHeaderContent()
       at Syncfusion.EJ.Export.GridWordExport.IterateElements()
       at Syncfusion.EJ.Export.GridWordExport.ExportHandler()
       at Syncfusion.EJ.Export.GridWordExport.MultipleColumnExport(Int32 count, Int32 templateColumncount, Int32 hideColumnCount)
       at Syncfusion.EJ.Export.GridWordExport.ExecuteResult(GridProperties GridModel, IEnumerable dataSource)
       at Syncfusion.EJ.Export.GridWordExport.Export(GridProperties gridModel, IEnumerable dataSource, Boolean multipleExport)
       at Syncfusion.EJ.Export.WordExport.Export(GridProperties gridmaodel, IEnumerable datasource, String fileName, Boolean isHideColumnIncude, Boolean isTemplateColumnIclude, Boolean isAutoFit, String theme)
       at Syncfusion.EJ.Export.WordExport.Export(GridProperties gridmaodel, IEnumerable datasource, String fileName, Boolean isHideColumnIncude, Boolean isTemplateColumnIclude, String theme)
       at Syncfusion.EJ.Export.WordExport.Export(GridProperties gridmaodel, IEnumerable datasource, String fileName, Boolean isHideColumnIncude, Boolean isTemplateColumnIclude, ExportTheme theme)
       at Troam.Website.Controllers.ProjectController.ExportToWord(String GridModel) in C:\Data\Software Development\Microsoft\Source\TROAM\Ntri.Troam\Source\Troam.Website\Controllers\ProjectController.cs:line 46
       at lambda_method(Closure , ControllerBase , Object[] )
       at System.Web.Mvc.ActionMethodDispatcher.<>c__DisplayClass1.<WrapVoidAction>b__0(ControllerBase controller, Object[] parameters)
       at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)
       at System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters)
       at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.<BeginInvokeSynchronousActionMethod>b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`2.CallEndDelegate(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResultBase`1.End()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3d()
       at System.Web.Mvc.Async.AsyncControllerActionInvoker.AsyncInvocationWithFilters.<>c__DisplayClass46.<InvokeActionMethodFilterAsynchronouslyRecursive>b__3f()
  InnerException: 


Regards
Prasanth


BM Balaji Marimuthu Syncfusion Team December 14, 2015 08:47 AM UTC

Hi Prasanthan,


We have created a sample as mentioned version and checked the reported issue from our end. But we are unable to reproduce the reported issue, so could you please share the following details?


1.     Scenario to reproduce the issue.

2.     Have you enabled any other features in Grid?

3.     Browser version details.

4.     Share sample/modify the attached sample as issue reproducible.


Refer to the sample in following link:

Sample: Exporting


Kindly, provide above details which will be helpful to find the cause of issue and provide you better solution at the earliest.


Regards,

Balaji Marimuthu



Loader.
Live Chat Icon For mobile
Up arrow icon