您可以使用requestEnd事件的数据源的检查,如果当前的操作为“创建”或“更新”并没有错误,以提醒用户。
样品MVC包装
@(Html.Kendo().Grid<ProductViewModel>()
.Name("grid")
.Columns(columns =>
{
columns.Bound(p => p.ProductName).Title("Product Name");
columns.Bound(p => p.UnitPrice).Title("Unit Price");
columns.Bound(p => p.UnitsInStock).Title("Units In Stock");
})
.Pageable()
.Sortable()
.DataSource(dataSource => dataSource
.Ajax()
// below is the RequestEnd event handler
.Events(events => events.RequestEnd("onRequestEnd"))
.Read(read => read.Action("Products_Read", "Grid"))
)
)
,这里是事件处理程序
function onRequestEnd(e) {
if (e.type == "update" && !e.response.Errors) {
// Update record is successfull, show your desired message
}
if (e.type == "create" && !e.response.Errors) {
// Create record is successfull, show your desired message
}
}