您可以使用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
}
}