I have the following Kendo grid:
@(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))
)
As you can see, I am using a popup dialog to edit a row. This creates a Kendo window with an update button, which will cause the Update method of the Notification controller to fire. If there is an error there, the error_handler specified above is called. This is it:
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";
});
}
});
}
}
I display any errors, and the Kendo window is dismissed (actually, the order is, dismiss window, then errors are displayed).
What I want to do instead:
If there is an error after the user clicks the Update button, call the update method, get the error and display it, and NOT DISMISS THE WINDOW. This will allow the user to correct the error and try again.
Thanks for reading.