- Home
- Forum
- ASP.NET MVC
- Delete Method with Composite Key
Delete Method with Composite Key
Thanks for using Syncfusion products.
We can achieve your requirement by passing the additional key values 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.
Refer to the below code example,
|
@(Html.EJ().Grid<OrderTable>("Grid") .Datasource(ds => ds.URL("GetOrderData") . . . . .RemoveURL("PerformDelete") .Adaptor(AdaptorType.UrlAdaptor) .ClientSideEvents(eve => { eve.ActionBegin("begin").ActionComplete("complete");}) ) <script type="text/javascript"> function begin(args) { if (args.requestType == 'delete') { args.model.dataSource.dataSource.headers = []; args.model.dataSource.dataSource.headers.push({ "additional_key": args.data.EmployeeID,"additional_key1":args.data.CustomerID }); } } 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 } //Perform delete public ActionResult PerformDelete(int key //primarykey value) {
NORTHWNDEntities db = new NORTHWNDEntities(); //getting additional key values int obj = Int32.Parse( Request.Headers.GetValues("additional_key")[0]); //key1 string obj1 = Request.Headers.GetValues("additional_key1")[0]; //key2 . . . . . . . . db.SaveChanges(); return RedirectToAction("GetOrderData"); } |
Refer to the below screenshot for more clarification,
Regards,
Gowthami V.
Thanks for your update.
We are happy that your requirement is achieved.
Regards,
Ragavee U S
- 3 Replies
- 3 Participants
-
TM Todd M
- Jan 4, 2016 04:40 AM UTC
- Jan 6, 2016 04:24 AM UTC