插入新记录时如何访问网格的现有行?
我有一个典型的基于 CRUD 的网格,我可以用 3 列进行编辑 - 姓名、职务、薪水.
当我插入或更新记录时,我想访问现有行中的"工资"数据 - 行[工资]。
如果平均"薪水"低于某个值,我不希望插入/更新成功。
查看剑道UI的示例代码,我想在ActionMethod中实现这一点
在索引剃刀页面:
.Create(create => create.Action("EditingCustom_Create", "Grid"))
.Update(update => update.Action("EditingCustom_Update", "Grid"))
在网格控制器的EditingCustom_Create操作方法中:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingCustom_Create([DataSourceRequest] DataSourceRequest request,
[Bind(Prefix = "models")]IEnumerable<ClientViewModel> client)
{
// I want to access the Salary values from each row here
// and get the Average to see if it's below/above a certain
// value before inserting/updating a record
var results = new List<ClientViewModel>();
...
...
return Json(results.ToDataSourceResult(request, ModelState));
}
我该怎么做?
http://demos.kendoui.com/web/grid/editing-custom.html
在批处理模式下编辑可以作为一种解决方案,因为操作方法会收到一个可以迭代的IEnumerable<..>
。
demos.kendoui.com/web/grid/editing.html