简体   繁体   English

使用Json填充剑道网格时出错

[英]Error populating a kendo grid using Json

I'm trying to fill a kendo grid from my controller, but my datasource has a entity class that can be null in some cases. 我正在尝试从控制器填充剑道网格,但是我的数据源有一个实体类,在某些情况下可以为null。 Everything work well, except when my entity has a null value. 一切正常,除非我的实体为空值。

  [HttpPost] public ActionResult Read([DataSourceRequest] DataSourceRequest request, Filter val) { List<Incidencia> vObj = _casosService.GetDatos(); if (null != val.Desc && val.Desc.Length > 0) vObj = vObj.Where(o => o.Description.ToLower().Contains(val.Desc.ToLower()) || o.Tittle.ToLower().Contains(val.Desc.ToLower()) .ToList(); return Json(vObj.OrderByDescending(o => o.Date).ToDataSourceResult(request, o => new { o.Id, o.EventDate, o.Description, o.System.shortName, o.Tittle, o.IdUserReport, o.Close, o.CloseDate, o.Customers.ShortName // <-- Throw an exception if has a null value. }) ); } 

I will appreciate your help. 感谢您的帮助。

为什么不执行以下操作?

  o.Customers != null ?   o.Customers.ShortName  : "" 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM