or
[Required(ErrorMessageResourceName = "ValeurRequise", ErrorMessageResourceType = typeof(GlobalesResources))]public int NoFormation { get; set; } @(Html.Kendo().Grid<MesFormations.Models.Employe>() .Name("Grid") .Columns(columns => { columns.ForeignKey(p => p.NoFormation, (System.Collections.IEnumerable)ViewBag.Formations, "Numero", "Description").Title(@MesFormations.Views.Employe.Resources.Titre).Width(240); columns.Bound(p => p.DateFormation).Width(90).Format("{0:yyyy-MM-dd}").HtmlAttributes(new { style = "text-align:center" }); columns.Bound(p => p.Remarques).Width(230); columns.Command(command => command.Destroy()).Width(110); }) .ToolBar(toolbar => { toolbar.Create(); toolbar.Save(); }) .Editable(editable => editable.Mode(GridEditMode.InCell)) .Pageable() .Sortable() .Scrollable() .Resizable(resizing => resizing.Columns(true)) .DataSource(dataSource => dataSource .Ajax() .Batch(true) .ServerOperation(false) .Events(events => events.Error("error_handler")) .Events(events => events.Change("onEdit")) .Model(model => model.Id(p => p.NoFormationEmploye)) .Create("Editing_Create", "Employe", new { NoEmploye = Model.NoEmploye }) .Read("Editing_Read", "Employe", new { NoEmploye = Model.NoEmploye }) .Update("Editing_Update", "Employe") .Destroy("Editing_Destroy", "Employe") ))catch (Exception ex) { ModelState.AddModelError("Error", ex.Message); return Json(ModelState.ToDataSourceResult(), JsonRequestBehavior.AllowGet); }function error(e) { if (e.errors) { var message = "Errors:\n"; $.each(e.errors, function (key, value) { if ('errors' in value) { $.each(value.errors, function () { message += this + "\n"; }); } }); alert(message); }}