[英]Ajax Binding a Kendo Grid with Asp.Net MVC doesn't display anything
I am trying to bind a Kendo Grid with Asp.Net MVC. 我正在尝试用Asp.Net MVC绑定剑道网格。 I show that grid in a detail page View with a lot of other fields... The records are coming correctly but nothing is displayed in the grid.
我在详细信息页面中显示该网格,其中包含许多其他字段...记录正确显示,但是网格中未显示任何内容。
Here is the Grid code, in the user control (ascx), of the View: 这是视图的用户控件(ascx)中的Grid代码:
<% Html.Kendo().Grid<Web.Areas.WorkOrder.ViewModels.PartListViewModel>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.GlassType);
columns.Bound(p => p.WorkType);
columns.Bound(p => p.PartNumber);
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("GetPartListInfo", "Claim", new { id = Model.JobId }))
.PageSize(5)
.ServerOperation(false)
)
.Pageable()
.Sortable()
.Groupable()
.Filterable()
.Render();
%>
The Model View looks like this: 模型视图如下所示:
public IEnumerable<PartListViewModel> PartList { get; set; }
public string VIN { get; set; }
public string Invoice { get; set; }
public string MileageKM { get; set; }
public EntityModel Provider { get; set; }
public string Comments { get; set; }
…etc, etc
This is the code from my Controller: 这是我的控制器中的代码:
public ActionResult GetPartListInfo([DataSourceRequest] DataSourceRequest request, string id)
{
XrmServiceContext xrmServiceContext = new XrmServiceContext();
workorder workOrder = xrmServiceContext.workorderSet.Where(i => i.Id == new Guid(id)).FirstOrDefault();
IEnumerable<PartListViewModel> parts = (xrmServiceContext.workorderproductSet.Where(prod => prod.WorkOrder.Id == workOrder.Id))
.Select(x => new PartListViewModel
{
WOId = id,
Id = x.f1_Product.Id.ToString(),
Quantity = 3,
PartNumber = "WS",,
WorkType = "Repair",
GlassType = "Windshield",
Price = 133
}).ToList();
return Json(parts.ToDataSourceResult(request));
}
Am I missing something in my configuration? 我的配置中缺少什么吗? I am wondering what is going wrong with it?
我想知道这是怎么回事? Thanks for any help you can provide.
感谢您的任何帮助,您可以提供。
尝试添加它以获取:
return Json(parts.ToDataSourceResult(request),JsonRequestBehavior.AllowGet);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.