【发布时间】:2018-06-11 05:56:25
【问题描述】:
我使用 ajax 从我的控制器(ShiftReports)读取数据。我还使用视图模型来合并两个表。 我现在不知道如何将 json 数组绑定或迭代到 kendo 列。
这是我的剑道 mvc 网格
@(Html.Kendo().Grid<PLIMO.ViewModel.MainEqpViewModel>()
.Name("MainEQP")
.DataSource(ds => ds
.Ajax()
.Read(read => read.Action("Eqp_Read", "ShiftReports"))
)
.Pageable()
.Sortable()
)
这是我的控制器
public ActionResult Eqp_Read([DataSourceRequest]DataSourceRequest request)
{
try {
using (var db = new DBContext())
{
db.Configuration.ProxyCreationEnabled = false;
var eqp = new MainEqpViewModel()
{
Tags = db.Tags.ToList(),
};
DataSourceResult result = new List<MainEqpViewModel>() { eqp }.ToDataSourceResult(request);
return Json(result);
}
}
catch(Exception ex)
{
return Json(ex.Message);
}
}
}
【问题讨论】:
-
所以你想返回一个标签列表到剑道网格?
-
您需要一个动态列。请参考示例代码dotnetlearningarray.blogspot.com/2015/06/…
标签: json model-view-controller kendo-ui grid