- Home
- Forum
- ASP.NET MVC
- Additional parameter to delete query (toolbar item)
Additional parameter to delete query (toolbar item)
Instead of using the additional parameters, we suggest using the Headers of the ejDataManager. While performing delete action in the actionBegin event, add the required number of array of objects into Headers and retrieve them using the Request Object of the HttpRequestMessage. Please refer to the below code example and screenshot.
|
@(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); |
Refer to the following Help Documents for APIs and User Guides.
http://help.syncfusion.com/js/api/ejgrid
http://help.syncfusion.com/aspnetmvc/grid/getting-started
Regards,
Seeni Sakthi Kumar S.
We are happy to hear that your issue has been resolved.
Get back to us if you need further assistance.
Regards,
Seeni Sakthi Kumar S.
- 3 Replies
- 2 Participants
-
OM Omar Muscatello
- Nov 17, 2015 05:27 PM UTC
- Nov 25, 2015 04:39 AM UTC