Asp.net mvc 剑道网格显示的是json数据,而不是实际的网格
我试图在剑道弹出窗口中启动剑道网格,但我得到的不是显示的网格,而是json数据 这是我的控制器的代码:Asp.net mvc 剑道网格显示的是json数据,而不是实际的网格,asp.net-mvc,json,kendo-ui,kendo-grid,Asp.net Mvc,Json,Kendo Ui,Kendo Grid,我试图在剑道弹出窗口中启动剑道网格,但我得到的不是显示的网格,而是json数据 这是我的控制器的代码: [HttpGet] public ActionResult Read([DataSourceRequest]DataSourceRequest request, int id) { var model = Service.FindOne("Cashflows", x => x.Id == id); var cashflows = new
[HttpGet]
public ActionResult Read([DataSourceRequest]DataSourceRequest request, int id)
{
var model = Service.FindOne("Cashflows", x => x.Id == id);
var cashflows = new List<flows>();
foreach (var cf in model.CashFlows)
{
var flow = new flows
{
Id = cf.Id,
AssetId = cf.Id,
MortgageValue = cf.MortgageValue,
Year = cf.Year
};
cashflows.Add(flow);
}
var result = cashflows.ToDataSourceResult(request);
return Json(result, JsonRequestBehavior.AllowGet);
}
[HttpGet]
公共操作结果读取([DataSourceRequest]DataSourceRequest请求,int-id)
{
var模型=Service.FindOne(“现金流”,x=>x.Id==Id);
var现金流=新列表();
foreach(模型现金流中的var cf)
{
var流量=新流量
{
Id=参考Id,
AssetId=参考Id,
抵押价值=cf.抵押价值,
年份=参照年份
};
现金流量。添加(流量);
}
var结果=现金流。ToDataSourceResult(请求);
返回Json(结果,JsonRequestBehavior.AllowGet);
}
这就是我对剑道的看法
@(Html.Kendo().Grid<ViewModels.Finance.flows>()
.Name("Grid")
.Columns(columns =>
{
columns.Bound(p => p.Id);
columns.Bound(p => p.AssetId);
columns.Bound(p => p.Year);
columns.Bound(p => p.MortgageValue);
})
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("Read", "Finance"))
.ServerOperation(false)
.PageSize(5)
)
.Pageable()
)
@(Html.Kendo().Grid())
.名称(“网格”)
.列(列=>
{
columns.Bound(p=>p.Id);
columns.Bound(p=>p.AssetId);
绑定列(p=>p.Year);
columns.Bound(p=>p.MortgageValue);
})
.DataSource(DataSource=>DataSource
.Ajax()
.Read(Read=>Read.Action(“Read”,“Finance”))
.ServerOperation(错误)
.页面大小(5)
)
.Pageable()
)
您需要将return命令更新为:
return Json(result.ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
检查是否包含所有必需的JS文件。返回JSON时使用AllowGet这一事实表明,这些文件可能不包括在内。