新しいレコードを挿入するときにグリッドの既存の行にアクセスするにはどうすればよいですか?
名前、役職、給与の 3 つの列で編集できる典型的な CRUD ベースのグリッドがあります。
レコードを挿入または更新するときに、既存の行 (row[Salary]) から「Salary」データにアクセスしたいと考えています。
平均「給与」が特定の値を下回っている場合、挿入/更新を成功させたくありません。
Kendo UI のサンプル コードを見ると、ActionMethod でこれを実現したいと考えています。
Index Razor ページで:
.Create(create => create.Action("EditingCustom_Create", "Grid"))
.Update(update => update.Action("EditingCustom_Update", "Grid"))
GridController の EditingCustom_Create ActionMethod で:
[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