0
votes

I am having problems while updating a cell in ag-grid in my angular 8 application. Please find the code below:

this.columns = [
    { headerName: '', field: 'enabled', width: 30, headerCheckboxSelection: true, checkboxSelection: true },
    { headerName: 'First Name', field: 'firstName', width: 100 },
    { headerName: 'Address', field: 'address', editable: true, width: 100 },
    { headerName: 'Address1', field: 'address1', editable: true, width: 70 }
];

this.rows = [
    {"first name1", "address", "address1"},
    {"first name2", "address", "address1"}
];

The above code allows me to update address and address1 fields, but when I try to get row data it is using the old values. Please find my code below to get data:

this.agGrid.api.forEachNode((node) => {
    console.log('-- the node data --', node.data);
});

What changes do I need to implement to get updated data from the ag-grid.

Thanks

1
have u handled getRowNodeId cellEditingStopped events? share your entire code OR reproduce your issue on plunk. - Paritosh
no, I haven't handled the above methods. The above code is all what I have now. Could you please share your's on plunk. - Ashy Ashcsi
As far as I tried, it is updating for me when I iterate using forEachNode() method. Share your component files (both TS and HTML) in which ag-grid table is displayed. If possible create a minimal reproducible app in Stackblitz. - Shravan

1 Answers

0
votes

You can access your data via your rows variable.

E.g.:

this.rows.forEach((row) => {
    console.log('-- row data --', row);
});

Please have a look at the ag-grid Update docs.