EJ2 Grid: Batch mode, trigger change in cell via JS

Hello,

This is kind of an odd one, but we are using our own persistence in a batch mode grid and when the user comes back, we reload where they were at with all of their data.  That works fine, but now because of it just being an array in the datasource, none of the cells are greens when they click save, the batchChanges arrays are empty.  How can we iterate through the cells and highlight them in green?

Currently we are doing:

function grid_items_to_inventory_dataBound(args){
            this.toolbarModule.enableItems(['grid_items_to_inventory_saveButton'], false); 
            console.log(this.currentViewData);
            for(var i=0;i<this.currentViewData.length;i++){
                if(this.currentViewData[i].warehouse_location_id){
                    this.editCell(i,'warehouse_location_id');
                    //this.setCellValue(this.currentViewData[i].id,'asset_number','test');
                }
            }
        }

It cycles through the cells and trips the cellSaved event but doesn't actually make the cell dirty.  We have tried the setCellValue which changes the cell value but again, does not make the cell dirty so it shows up in green.  Any thoughts?

3 Replies 1 reply marked as answer

MS Manivel Sellamuthu Syncfusion Team April 16, 2021 11:06 AM UTC

Hi Mark, 
 
Greetings from Syncfusion support. 
 
We have validated your requirement. From your requirement we can understand that you want to edit the cells in the initial loading. For that requirement you can use the updateCell method of the Grid component. We have demonstrated this in the below code example. 
 
        dataBound() { 
            console.log(this.currentViewData); 
            if (flag) { 
              flag = false; 
            for(var i=0;i<this.currentViewData.length;i++){ 
                if(this.currentViewData[i].CustomerID){ 
                                   //(rowindex, field, value) 
                    this.updateCell(i,'CustomerID' ,'test'); 
                } 
            } 
            } 
        }, 
 
 
Please let us know if you need further assistance. 
 
Regards, 
Manivel 


Marked as answer

MA Mark April 16, 2021 01:05 PM UTC

Hey!  That worked perfectly.  So that is one of the few I didn't try because the docs state it doesn't change the cell into the edited state and I thought that is what we needed to make it "isDirty".  None the less, that works amazingly well, so thank you again!!


MS Manivel Sellamuthu Syncfusion Team April 19, 2021 04:19 AM UTC

Hi Mark, 

Thanks for your update. 

We are glad that the provided solution worked. 

Please let us know if you need further assistance. 

Regards, 
Manivel 


Loader.
Up arrow icon