Refresh a cell in a Grid

I'm sorry but I know I have seen where you folks have given a link to how to refresh the data in a individual cell and I can't find it.  Can you point me in the right direction?  I need to change the value to an item in one array and then need to sync that value to a different array.  Refreshing the entire grid is a little too much. Thank you


3 Replies

VS Vignesh Sivagnanam Syncfusion Team July 27, 2021 04:54 PM UTC

Hi William 

Greetings from Syncfusion support 

Based on you query, we suspect that you want to change the value of the particular cell and refresh the cell without move it in to the edit state. By default in EJ2 Grid, there is no such type of editing for the particular cell. To achieve your requirement, we suggest you to use the EJ2 Grid’s setCellvalue method to update the particular cell in the grid without moving it to edit state.  

Using the setCellValue method in the grid, you need to provide any of the column as primaryKey column that contains unique value.  

Please refer the below Documentation for your reference, 


Or, you can use the EJ2 Grid’s updateRow method and it is used to Update the row values and refresh the particular row in the UI and also in the grid DataSource. Please refer the below documentation for more information. 


Regards 
Vignesh Sivagnanam 



WM William Morgenweck August 27, 2021 11:37 AM UTC

I didn't see any information about update Row in the documentation and I have no idea what update cell is trying to tell me. 

Can you give a simple line of code for both updating a cell and a row?


Thank you



VS Vignesh Sivagnanam Syncfusion Team August 30, 2021 04:41 PM UTC

Hi William 

Thanks for the update 

Based on your query, we could understand that you need code snippets for the EJ2 Grid updateRow and updateCell methods. Please find the example for the both methods below. 

1. updateRow 

The updateRow method is used to update the row values and refresh the particular row in the UI and also in the grid DataSource. Please refer the below code example, 

Change : function(args) { 
                                                                                      //grid – Grid instance. 
            grid.updateRow(index, data);                     //index – row index of the row you want to change 
                                                                                     //data – data you want to update to the row 

2. updateCell 

The EJ2 Grid updateCell method is used to update the specified cell by given value without changing into edited state. We would like to let you know that the updateCell method can be used only with ‘Batch’ edit mode of the Grid. 


Change : function(args) { 
                                                                                       //grid – Grid instance. 
          grid.updateCell(index, "ShipCity", value);    //index – row index of the row you want to change 
                                                                                       //value – value you want to update to the cell 
                                                                                       // ShipCity – Grid column of the cell  

Regards 
Vignesh Sivagnanam 


Loader.
Up arrow icon