Auto Save

How can I commit changes to the database on cell save in batch save mode in a Datagrid?

5 Replies

RR Rajapandi Ravi Syncfusion Team May 25, 2020 12:04 PM UTC

Hi Henry, 
 
Greetings from syncfusion support 
 
Before start providing solution on your query, we need more information for our clarification. So please share the below details that will be helpful for us to provide better solution. 

1)     Please confirm whether you want to perform the save action without clicking on update icon? 

2)     In your application you have used Grid with local binding or remote binding? 
  
Regards, 
Rajapandi R 



HW Henry Wokhwera May 25, 2020 01:12 PM UTC

Yes I want to perform the save action without clicking on the update icon and  Below is my Data
manager which I believe is the local binding 


 <e-data-manager url="/CommonMarket/DataSourceCommonMarket" batchUrl="/CommonMarket/MarketBatchUpdate" adaptor="UrlAdaptor"></e-data-manager>



AG Ajith Govarthan Syncfusion Team May 26, 2020 02:34 PM UTC

Hi Henry, 

Thanks for the update. 

To achieve your requirement we suggest you to call batchSave method of EJ2 Grid in the cellSaved event. For your convenience we have attached the sample so please refer the sample for your reference. 

Code Snippet:  
Index.cshtml 

<ejs-grid id="Grid" allowPaging="true"  cellSaved="cellSaved"  toolbar="@(new List<string>() { "Add", "Edit", "Delete", "Update", "Cancel" })"> 
    <e-data-manager url="/home/UrlDatasource" batchUrl="/Home/BatchUpdate" adaptor="UrlAdaptor"></e-data-manager> 
    <e-grid-editSettings allowAdding="true" allowDeleting="true" allowEditing="true" mode="Batch" showConfirmDialog="false"></e-grid-editSettings> 
    <e-grid-columns> 
        <e-grid-column field="OrderID" headerText="Order ID" isPrimaryKey="true" textAlign="Right" width="120"></e-grid-column> 
        <e-grid-column field="CustomerID" headerText="Customer ID" width="150"></e-grid-column> 
        <e-grid-column field="EmployeeID" headerText="Employee ID" width="130" textAlign="Right"></e-grid-column> 
        <e-grid-column field="ShipCity" headerText="ShipCity" width="120"></e-grid-column> 
    </e-grid-columns> 
</ejs-grid> 
 
<script> 
    function cellSaved(args) { 
        this.editModule.batchSave(); 
    } 
</script> 



Please get back to us if you need further assistance. 

Regards, 
Ajith G. 



HW Henry Wokhwera May 27, 2020 08:54 AM UTC

Thank you very much, it worked


AG Ajith Govarthan Syncfusion Team May 28, 2020 02:05 PM UTC

Hi Henry, 

Thanks for the update. 

We are happy to hear that your issue is resolved. 

Please get back to us if you need further assistance. 

Regards, 
Ajith G. 


Loader.
Up arrow icon