- Home
- Forum
- ASP.NET MVC
- NullReferenceException excelexport syncfusion grid
NullReferenceException excelexport syncfusion grid
I am using ASP .Net MVC angular js, syncfusion grid.
This error happens when the grid's datarow is filtered via js 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:
var obj = $("#MyGrid").ejGrid("instance");
obj.filterColumn("ClientID", "equal", Id_ "and", true);
this is because I have a custom toolbar (not the one in the grid) that has dropdown of list of clients, and I need to filter the rows according to selected client.
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;
},exporting js: var gridObj = $("#myGrid").data("ejGrid");
gridObj.export(url);
controller:
[System.Web.Http.ActionName("ExcelExport")]
[AcceptVerbs("POST")]
public void ExportToExcel()
{
string gridModel = HttpContext.Request.Params["GridModel"];
GridProperties gridProperty = ConvertGridObject(gridModel);
ExcelExport exp = new ExcelExport();
var items = _svc.GetItems(someFilters);
exp.Export(gridProperty, items, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron"); //the error is in this line
}
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.<WrapVoidAction>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.<BeginInvokeSynchronousActionMethod>b__41() +33
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +56
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +76
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +370
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +370
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult) +57
System.Web.Mvc.Async.<>c__DisplayClass2a.<BeginInvokeAction>b__20() +32
System.Web.Mvc.Async.<>c__DisplayClass25.<BeginInvokeAction>b__22(IAsyncResult asyncResult) +184
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +50
System.Web.Mvc.<>c__DisplayClass1d.<BeginExecuteCore>b__18(IAsyncResult asyncResult) +24
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +22
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +64
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>b__3(IAsyncResult ar) +22
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +50
System.Web.Mvc.<>c__DisplayClass8.<BeginProcessRequest>b__3(IAsyncResult asyncResult) +38
System.Web.Mvc.Async.<>c__DisplayClass4.<MakeVoidDelegate>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
the same, and confirmed by the fact that it exports if the grid is not
filtered. Also, they have the same 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?
SIGN IN To post a reply.
1 Reply
TS
Thavasianand Sankaranarayanan
Syncfusion Team
December 11, 2017 11:40 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.
- Share the screenshot/ video of the issue that you have faced.
- Share the Syncfusion Essential studio version details that you are using.
- Share the columns details that you are using.
- Share the adaptor details that you are using in grid.
- 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,
Thavasianand S.
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
US userDP
- Dec 8, 2017 03:32 PM UTC
- Dec 11, 2017 11:40 AM UTC