2016-05-24 12 views
2

私の剣道グリッド(インライン編集)でレコードが正常に更新されたら、別の成功メッセージを返したいと思います。私がしたいのは、このようなものです(ModelState.AddModelErrorに似たポップアップを返信し、成功メッセージとしてのみ)。私はModelStateが "Success"と同等のものを持っていないことを知っているので、これがどのように達成されるのかと思っています。剣道グリッドのカスタム成功メッセージ

if (MyBool == true) 
{ 
    //custom message one 
} 
else 
{ 
    //custom message two 
} 

return Json(ModelState.ToDataSourceResult()); 

答えて

0

現在の操作は、「作成」または「更新」であるとユーザーに警告するエラーがないかどうかをチェックするためにデータソースの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 
    } 
} 
です
関連する問題