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.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Batch Edit

Thread ID:

Created:

Updated:

Platform:

Replies:

129735 Mar 31,2017 05:53 AM Apr 3,2017 07:57 AM ASP.NET MVC 1
loading
Tags: Grid
Avi Segal
Asked On March 31, 2017 05:53 AM

Hi,

EditMode.Batch.

Is it possible to save changes to each row in the grid after moving to the next one, instead of saving the entire batch? 

Farveen Sulthana Thameeztheen Basha [Syncfusion]
Replied On April 3, 2017 07:57 AM

Hi Avi Segal, 


Thanks for contacting syncfusion support. 


We have achieved your requirement “save changes to each row in the grid instead of saving the entire batch” using “CellSave” event of the grid. In the cellSave event, we can get the batch changes by using “getBatchChanges” method and finally save the records in the “batchSave” method instead of saving the entire batch. CellSave event will be triggered at each cell save. If you have called the batchSave method within this event, it will update the Grid DataSource instantly. 


Please refer the API reference link:- 








Please refer to the code example:- 

    
@(Html.EJ().Grid<object>("FlatGrid") 
     .Datasource((IEnumerable<object>)ViewBag.datasource) 
     .EditSettings(edit => { edit.AllowAdding().AllowDeleting().AllowEditing().EditMode(EditMode.Batch); }) 
     .ToolbarSettings(toolbar =>{ 
                        toolbar.ShowToolbar().ToolbarItems(items => 
                        { 
                            items.AddTool(ToolBarItems.Add); 
                            items.AddTool(ToolBarItems.Edit); 
                            items.AddTool(ToolBarItems.Delete); 
                            items.AddTool(ToolBarItems.Update); 
                            items.AddTool(ToolBarItems.Cancel); 
              }); 
           }) 
   .AllowPaging() 
   .ClientSideEvents(eve => { eve.CellSave("cellsave"); }) 
   .Columns(col => 
   { 
       col.Field("OrderID").HeaderText("Order ID").IsPrimaryKey(true).Add(); 
       col.Field("CustomerID").HeaderText("Customer ID").Add(); 
        .  .  . 
  }) 
 
) 
   
<script type="text/javascript"> 
    var flag = true; 
    function cellsave(args) { 
        if (flag) { 
            args.cancel = true; 
            if ($.inArray(args.rowData, this.batchChanges.changed) == -1 && $.inArray(args.rowData, this.batchChanges.added) == -1) 
               this.batchChanges.changed.push(args.rowData); 
            var batchData = this.getBatchChanges(); 
            var batchDetails = this._bulkEditCellDetails; 
            if (batchData.added.length > 0 || batchData.changed.length > 0 || batchData.deleted.length > 0) { 
                flag = false; 
                this.batchSave(); 
                this._bulkEditCellDetails = batchDetails;//reassigning the values  
            } 
        } 
        else 
            flag = true; 
    }; 
 
</script>  




Regards, 

Farveensulthana T 


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.

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

;