@(Html.EJ().Grid<OrdersView>("BatchEditing") .Datasource(ds => ds.URL(@Url.Action("DataSource")).BatchURL(@Url.Action("UpdateBatch")).Adaptor(AdaptorType.UrlAdaptor)) . . . . .Columns(col => { . . . .. }) .ClientSideEvents(events => { events.ActionFailure("Failure"); }) )
<script> function Failure(args) { args.error//retreive the error message-check the attached sample for example } namespace MvcApplication66.Controllers { public class HomeController : Controller { . . . . . . . . . public ActionResult UpdateBatch(List<EditableOrder> changed, List<EditableOrder> added, List<EditableOrder> deleted) { if (added != null) { for (int i = 0; i < added.Count(); i++) { if (added[i].OrderID < 1000) throw new InvalidOperationException("OrderID must be above 1000");//Throwing exception for sample purpose } OrderRepository.Add(added); } . . . . . . .. var data = new NorthwindDataContext().OrdersViews.ToList(); return Json(data, JsonRequestBehavior.AllowGet); } . . . . } |