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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Save Additional Parameter with grid data

Thread ID:

Created:

Updated:

Platform:

Replies:

140577 Oct 26,2018 02:39 AM UTC Oct 26,2018 07:12 AM UTC ASP.NET Core - EJ 2 1
loading
Tags: Grid
haryzad
Asked On October 26, 2018 02:39 AM UTC

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

Venkatesh Ayothi Raman [Syncfusion]
Replied On 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. 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;