@(Html.EJ().Grid<MvcApplication66.OrdersView>("FlatGrid") .Datasource(ds => ds.URL("/Home/DataSource").UpdateURL("/Home/Update").RemoveURL("/Home/Delete").Adaptor(AdaptorType.UrlAdaptor)) .AllowFiltering() .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing(); }) .ToolbarSettings(tools => { tools.ShowToolbar().ToolbarItems(items => { . . . . items.AddTool(ToolBarItems.Delete); } ); }) .ClientSideEvents(events => { events.ActionBegin("begin").ActionComplete("complete"); }) .Columns(col => { col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).TextAlign(TextAlign.Right).Width(75).Add(); . . . . . })) <script> function begin(args) { if (args.requestType == 'delete') { args.model.dataSource.dataSource.headers = []; args.model.dataSource.dataSource.headers.push({ " additional_key": " myvalue" }) } } function complete(args) { if (args.requestType == 'delete') args.model.dataSource.dataSource.headers = [];//to avoid headers value to be interfered with other actions, emptied the Headers }
public ActionResult Delete(int key) { var obj = Request.Headers.GetValues("additional_key")[0]; var data = OrderRepository.GetAllRecords(); return Json(data, JsonRequestBehavior.AllowGet); |