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.