How do I access a grid's existing rows when I insert a new record?
I have a typical CRUD based grid that I can edit with 3 columns - Name, Title, Salary.
When I insert or update a record, I want to access the 'Salary' data from the existing rows - row[Salary].
If the average 'Salary' is below a certain value, I don't want the Insert/Update to be successful.
Looking at the sample code from Kendo UI, I would like to achieve this in the ActionMethod
in the Index Razor page:
.Create(create => create.Action("EditingCustom_Create", "Grid"))
.Update(update => update.Action("EditingCustom_Update", "Grid"))
in the EditingCustom_Create ActionMethod of the GridController:
[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));
}
How can I do this?
http://demos.kendoui.com/web/grid/editing-custom.html