We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Delete using composite key

Hi,

Is there any way of passing a composite key instead of just the Key to a back end service when using the UrlAdaptor?  



Thanks


1 Reply

MS Mani Sankar Durai Syncfusion Team November 10, 2017 12:22 PM UTC

Hi Mahindra, 

Thanks for contacting Syncfusion support. 

We have analyzed your query and we found that you want to pass the composite key to server side while deleting the record in grid. We can achieve it by passing through the headers while deleting. Based on your requirement we have prepared a sample that can be downloaded from the below link 

Refer the code example 
 
        <ej-grid id="Grid" allow-paging="true" action-begin="begin"> 
            <e-datamanager url="/Home/DataSource" insert-url="/Home/NormalInsert" update-url="/Home/NormalUpdate" remove-url="/Home/NormalDelete" adaptor="UrlAdaptor" /> 
            <e-edit-settings allow-adding="true" allow-editing="true" allow-deleting="true" edit-mode="Normal" show-delete-confirm-dialog="true" /> 
            <e-toolbar-settings show-toolbar="true" toolbar-items='@new List<string> {"add","edit","delete","update","cancel"}' /> 
            <e-columns> 
... 
            </e-columns> 
 
        </ej-grid> 
    
<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.ShipCity }); 
        } 
    } 
     
</script> 
 
[HomeController.cs] 
public ActionResult NormalDelete([FromBody]CRUDModel<OrderDetails> value) 
        { 
            int obj = Int32.Parse(Request.Headers["additional_key"]); //key1 
            string obj1 = Request.Headers["additional_key1"]; //key2 
            order.Remove(order.Where(or => or.OrderID == int.Parse(value.Key.ToString())).FirstOrDefault()); 
            return Json(value); 
        } 

From the above code example we have achieved it using action-begin event in grid  
Refer the API link 
Link:  
Please let us know if you need further assistance. 

Regards, 
Manisankar Durai. 


Loader.
Live Chat Icon For mobile
Up arrow icon