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

How to access the values in a grid from the template columns

Hi Support:

I have a view with a grid.  The grid datasource is populated with a ViewBag.

The grid will display data that can only be edited.

Two columns are template columns.  The first is a checkbox and the other is an input box.  We decided to use templates because the checkbox should be clickable with a single click and the other template (input) is because is displayed only in certain rows.

Outside the grid there is a Save button.  The goal is that when the save button is clicked, the new data must be transferred to the server via ajax.

The problem is that I dont know how to read the values from the grid, because the dataSource property does not have the modifications.

Please help.

Thanks in advanced

David

1 Reply

VN Vignesh Natarajan Syncfusion Team September 5, 2017 01:22 PM UTC

Hi David, 

Thanks for using Syncfusion products. 

We have analyzed your query. From your requirement ”checkbox should be clickable with a single click” so we suggest you to use batch editing with checkbox column to achieve your requirement. Please refer the below image for same 

 



We have prepared the sample based your requirement. 
Query2: “ I dont know how to read the values from the grid” 

              On the ej-Button’s click event we have taken the Grid Instance and called the batchsave() method, which will  call batch-url and update the modified data into database. Please refer below code snippet. 

<ej-button id="button_button" text="Save" show-rounded-corner="true" size="Mini" type="Button"> 
                        . 
                        . 
<script type="text/javascript"> 
 
        $("#button_button").click(function () { 
            var gud = $("#FlatGrid").ejGrid("instance"); //Grid instance 
            gud.batchSave(); // calling the batcsave method 
        }); 
    </script> 
     
Please refer our online documentation for your reference 


Regards, 
Vignesh Natarajan 


Loader.
Up arrow icon