kendo-ui - Kendo Window - 使用自定义更新
问题描述
我有以下剑道网格:
@(Html.Kendo().Grid<Mizuho.AMS.Models.AMSServiceProcessNotificationModel>()
.Name("grd")
.ToolBar(toolBar =>
{
toolBar.Create();
})
.Sortable()
.Scrollable(a => a.Height("auto"))
.Filterable(s => s.Enabled(false))
.Selectable(s => s.Enabled(false))
.Pageable(p => p.Enabled(true).Refresh(true).PageSizes(new List<string> { "all", "10", "15", "20", "50" }))
.HtmlAttributes(new { style = "width: 100%;" })
.Editable(e => e.Mode(GridEditMode.PopUp).TemplateName("NotificationEditor").Window(w => w.Width(700)))
.Columns(columns =>
{
columns.Bound(s => s.ProcessId).Width(90);
columns.Bound(s => s.NotificationType).Width(140);
columns.Bound(s => s.NotificationAction).Width(140);
columns.Bound(s => s.Parameters).Width(680);
columns.Command(cmd => { cmd.Edit(); cmd.Destroy(); });
})
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.PageSize(15)
.Events(events => events.Error("error_handler"))
.Model(model =>
{
model.Id(s => s.ID);
})
.Read(read => read.Action("Read", "Notification"))
.Create(create => create.Action("Create", "Notification"))
.Update(update => update.Action("Update", "Notification"))
.Destroy(destroy => destroy.Action("Destroy", "Notification"))
)
.Resizable(resize => resize.Columns(true))
)
如您所见,我正在使用弹出对话框来编辑一行。这将创建一个带有更新按钮的 Kendo 窗口,这将触发 Notification 控制器的 Update 方法。如果那里有错误,则调用上面指定的 error_handler。就是这个:
function error_handler(e) {
if (e.errors) {
var message = "";
$.each(e.errors, function (key, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
}
}
我显示任何错误,然后关闭 Kendo 窗口(实际上,顺序是关闭窗口,然后显示错误)。
我想做的是:
如果用户单击更新按钮后出现错误,则调用更新方法,获取错误并显示它,而不是关闭窗口。这将允许用户更正错误并重试。
谢谢阅读。
解决方案
推荐阅读
- c# - Winform 进度条仅在进程完成时更新(C#、Python)
- javascript - Why doesn't Typescript infer return values correctly when possible return object types are specifically defined?
- python - 根据 x['dob'] 和 x['ReferenceDate'] 计算年龄 - Pandas
- r - 获取对数据集并将其定向以将焦点移至所有唯一值的左列,并在右侧显示所有对组合,尽管方向
- regex - Teradata REGEX 或 SUBSTR 删除两个 * 和星号之间的文本?
- graphite - Spring Boot Micrometer 分层度量命名空间串联
- docker - 带有 RabbitMQ 的 Docker 容器崩溃
- reactjs - React-Testing-Library - useReducer 调度不更新测试的组件状态
- sql-server - EF Core 3.1.9 - 使用存储过程的 FromRawSql 停止工作 - “底层读取器没有预期的那么多字段。”
- python-3.x - 为什么firefox在第四次运行后总是挂断