我正在使用ASP .Net MVC angular js,syncfusion grid。
当网格的数据流被过滤时会发生此错误,但如果未应用过滤器,则会发生此错误。我需要过滤网格,所以不过滤它是不可能的。
我的过滤器编码如下:
obj.filterColumn("ClientID", "equal", Id_ "and", true);
我的网格:
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;
},
export js:
var gridObj = $("#myGrid").data("ejGrid");
gridObj.export(url);
控制器:
[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 i in this line
}
堆栈跟踪:
[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
我确信网格中的列和项目的数据源是相同的,并且如果没有过滤gird,它会导出它。此外,有相同的行,但我不认为这很重要,因为我尝试导出行数不同于行的项目行,并导出很好。
我该如何纠正?
答案 0 :(得分:0)
我检查了您的查询,但我无法重现报告的问题。请在下面找到示例链接
链接:http://www.syncfusion.com/downloads/support/forum/134986/ze/Exporting-743928412
如需检查,请提供以下详细信息,