我在尝试将 KendoUI Grid 用于在 Visual Studio 2013 中开发的 ASP.NET MVC (.net 4.5) 应用程序时遇到异常。我已将网格配置为使用内联编辑并在数据源部分。这被渲染为部分视图。需要注意的是,如果 GridEditMode.InLine 设置为 GridEditMode.InCell 则不会抛出异常。
例外
您必须使用 InCell 编辑模式进行批量更新。
说明:执行当前 Web 请求期间发生未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。
异常详细信息:System.NotSupportedException:您必须使用 InCell 编辑模式进行批量更新。
代码
@using Kendo.Mvc.UI
@model MyApp1.Data.DataModels.Agent
@(Html.Kendo().Grid<MyApp1.Data.ViewModels.PhoneNumberVM>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.Number);
columns.Bound(p => p.Description);
columns.Command(command => command.Edit()).Width(90);
columns.Command(command => command.Destroy()).Width(90);
})
.ToolBar(toolBar =>
{
toolBar.Create().Text("Add Phone Number");
toolBar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.DataSource(dataSource => dataSource
.Ajax()
.Batch(false)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(p => p.PhoneNumberId);
model.Field(p => p.PerId).Editable(false).DefaultValue(@Model.PerId);
})
.Read(read => read.Action("_GetPhones", "Pers", new { AgentId = Model.AgentId }))
.Create(create => create.Action("_AddPhone", "Pers"))
.Update(update => update.Action("_EditPhone", "Pers"))
.Destroy(destroy => destroy.Action("_DeletePhone", "Pers"))
)
)