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
close icon

Save Additional Parameter with grid data

Dear Syncfusion Team

Can you advice.

Currently i have the form with few field (dropdown) with datagrid (using ejs-grid mode normal).
During the grid CRUD, i want to bring also the information outside from the grid to save. The details as per in attachment.

Appreciate on your feedback

Thanks


Attachment: Support_1_a52f5815.rar

1 Reply

VA Venkatesh Ayothi Raman Syncfusion Team October 26, 2018 07:12 AM UTC

Hi Haryzad, 

Thanks for contacting Syncfusion Support. 

You can achieve your requirement by using the query property of the Grid component. We have prepared a simple sample based on your requirement in which we have added the additional parameter to the Grid query property in the actionBegin event which will be triggered before save the edited data. Please refer to the below code example, documentation link and sample link. 

[index.cshtml] 
 
<div class="control-wrapper"> 
    <div id="default" style='width:50%'> 
        Document Type: 
        <ejs-dropdownlist id="type" dataSource="@(new List<string>() { "PDF", "Excel", "CSV" })" placeholder="Select a type" popupHeight="220px"> 
        </ejs-dropdownlist> 
    </div> 
</div> 
<ejs-grid id="Grid" query="new ej.data.Query().addParams('type', 'default')" actionBegin="begin" height="273" toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Cancel", "Update" })"> 
 
    <e-grid-columns> 
     .  .  .. 
    </e-grid-columns> 
</ejs-grid> 
 
<script> 
    function begin(e) { 
        var grid = document.getElementsByClassName('e-grid')[0].ej2_instances[0]; 
        var type = document.getElementById('type').ej2_instances[0]; 
        if (e.requestType == "save") {    // triggers before saving the data          
            grid.query.params.filter((e) => e.key == 'type')[0].value = type.value; 
        } 
    } 
    </script> 

[controller] 
public ActionResult Update([FromBody] CRUDModel myObject) 
        { 
            var ord = myObject.Value; 
            OrdersDetails val = orddata.Where(or => or.OrderID == ord.OrderID).FirstOrDefault(); 
            val.OrderID = ord.OrderID; 
            .  .  . 
            return Json(myObject.Value); 
 
        } 
public class CRUDModel 
        { 
            public OrdersDetails Value { get; set; } 
            public string type { get; set; } 
            .  .  . 
       } 

 

                               https://ej2.syncfusion.com/documentation/grid/api-grid.html?lang=typescript#actionbegin  


Please let us know if you have any further assistance on this. 
 
Regards, 
Venkatesh Ayothiraman. 


Loader.
Live Chat Icon For mobile
Up arrow icon