【问题标题】:How to access rows in Kendo UI Grid with ASP.NET MVC如何使用 ASP.NET MVC 访问 Kendo UI Grid 中的行
【发布时间】:2013-10-03 04:33:05
【问题描述】:

插入新记录时如何访问网格的现有行?

我有一个典型的基于 CRUD 的网格,我可以用 3 列进行编辑 - 姓名、职务、薪水。
当我插入或更新记录时,我想从现有行访问“薪水”数据 - 行 [薪水]。

如果平均“工资”低于某个值,我不希望插入/更新成功。
查看来自 Kendo UI 的示例代码,我想在 ActionMethod 中实现这一点

在索引剃刀页面中:

.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

【问题讨论】:

  • 如果你这样做是批处理模式,有一个示例 kendo-ui 演示站点demos.kendoui.com/web/grid/editing.html 演示了如何访问批处理模式更新中的项目。看看批量编辑部分。

标签: asp.net-mvc asp.net-mvc-4 kendo-ui kendo-grid kendo-asp.net-mvc


【解决方案1】:

在批处理模式下编辑可以作为一种解决方案,因为 Action 方法接收到 IEnumerable&lt;..&gt; - 可以迭代。

demos.kendoui.c​​om/web/grid/editing.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-30
    • 1970-01-01
    • 1970-01-01
    • 2013-09-14
    • 1970-01-01
    • 2016-06-23
    相关资源
    最近更新 更多