How to update the edit grid data when grid is editing

Hi,

https://ej2.syncfusion.com/angular/demos/#/tailwind/grid/template-driven-form

When the edit grid is current editing, I want to click a button to change the grid datasource. But cannot endedit the grid, and cannot refresh the grid. How to show the correct data in grid interface?



1 Reply

PS Pavithra Subramaniyam Syncfusion Team November 29, 2021 01:00 PM UTC

Hi lorryl, 

Thanks for contacting Syncfusion support. 

You can achieve your requirement by calling the “endEdit” method after you have set the dataSource. This will save the record which is in edited state. And see the data source changes by calling the “refresh” method inside the “actionComplete” event with “save” requestType. Please refer to the below code example, documentation and sample link for more information.  

actionBegin(args: SaveEventArgs): void { 
    .  .  . 
    if (args.requestType === 'save') { 
      // To Change the edited record value 
      args.data['Freight'] = 1; 
       
    } 
  } 
 
  actionComplete(args: DialogEditEventArgs): void { 
    .  .  . 
    if (args.requestType == 'save') { 
      this.grid.refresh(); 
    } 
  } 
  click(e) { 
    this.data.forEach((row) => { 
      row['Freight'] = 1; 
    }); 
    this.grid.endEdit(); 
  } 


Documentation : https://ej2.syncfusion.com/documentation/api/grid/#endedit
                               https://ej2.syncfusion.com/documentation/api/grid/#refresh 


Please get back to us if you need further assistance on this. 

Regards, 
Pavithra S 


Loader.
Up arrow icon