ExcelExport Object reference not set to an instance of an object.

This error happens when the grid's data is filtered but works if no filter is applied. I need to filter the grid so not filtering it is out of question.
my filter is coded like this:

 obj.filterColumn("ClientID", "equal", Id_ "and", true);

my grid:

jQuery("#myGrid").ejGrid({
           dataSource: dataManager,
           columns: cols,
           allowSelection: true,
           enableAltRow: false,
           enableRowHover: true,
           isResponsive: true,
           allowSearching: true,
           selectionSettings: { selectionMode: ["row"] },
           allowFiltering: true,
           allowSorting: true,
           allowScrolling: true,
           allowResizeToFit: true,
           allowPaging: true,
           pageSettings: { pageSize: 12 },
           toolbarSettings: { showToolbar: true, toolbarItems: [ej.Grid.ToolBarItems.ExcelExport] },
           toolbarClick: function (e) {
               this.exportGrid = this["export"];
               if (e.itemName == "Excel Export") {
       
                   this.exportGrid('/MyController/ExportToExcel')
                   e.cancel = true;
              
           },

stacktrace:

    [NullReferenceException: Object reference not set to an instance of an object.]
       Syncfusion.JavaScript.DataSources.DataOperations.PerformFiltering(IEnumerable dataSource, List`1 filteredColumns) +193
       Syncfusion.JavaScript.DataSources.DataOperations.Execute(IEnumerable dataSource, GridProperties property) +61
       Syncfusion.EJ.Export.GridExcelExport.ExecuteResult(GridProperties GridModel, Object dataSource) +431
       Syncfusion.EJ.Export.GridExcelExport.ExportHelper(GridProperties gridModel, Object dataSource) +777
       Syncfusion.EJ.Export.GridExcelExport.Export(GridProperties gridModel, Object dataSource, Boolean multipleExport) +20
       SwapZilla.Controllers.CollateralPostingController.ExportToExcel() in D:\Dev\MyProject\Controllers\MyController.cs:187
       System.Web.Mvc.<>c__DisplayClass1.b__0(ControllerBase controller, Object[] parameters) +15
       System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +252
       System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +34
       System.Web.Mvc.Async.<>c__DisplayClass42.b__41() +33
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +56
       System.Web.Mvc.Async.<>c__DisplayClass39.b__33() +76
       System.Web.Mvc.Async.<>c__DisplayClass4f.b__49() +370
       System.Web.Mvc.Async.<>c__DisplayClass4f.b__49() +370
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +57
       System.Web.Mvc.Async.<>c__DisplayClass2a.b__20() +32
       System.Web.Mvc.Async.<>c__DisplayClass25.b__22(IAsyncResult asyncResult) +184
       System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +50
       System.Web.Mvc.<>c__DisplayClass1d.b__18(IAsyncResult asyncResult) +24
       System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +22
       System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +64
       System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +22
       System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +50
       System.Web.Mvc.<>c__DisplayClass8.b__3(IAsyncResult asyncResult) +38
       System.Web.Mvc.Async.<>c__DisplayClass4.b__3(IAsyncResult ar) +22
       System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +50
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +607
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +134

I am sure that the columns in the grid and datasource of items are thesame, and confirmed by the fact that it exports if there grid is not filtered. Also, they have the same number of rows but I don't think it matters, because I tried exporting rows of items with different no of rows than the grid and it exported fine.


How can I correct this?

thanks.

1 Reply

MS Mani Sankar Durai Syncfusion Team December 11, 2017 11:48 AM UTC

Hi Theresa, 

Thanks for contacting Syncfusion support.  

We have analyzed your query and we are not able to reproduce the reported issue. We have also prepared a sample that can be available from the below link 
If you still face the issue please get back to us with the following details.  
1.       Share the screenshot/ video of the issue that you have faced.  
2.       Share the Syncfusion Essential studio version details that you are using.  
3.       Share the grid columns details that you are using.  
4.       Share the adaptor details that you are using in grid.  
5.       If possible please reproduce the issue in the above attached sample  
The provided information will help us to analyze the issue and provide you the response as early as possible  

Regards, 
Manisankar Durai. 


Loader.
Up arrow icon