I just wanted to give the functionality of edit in my grid and my data was coming from a NGRX state. So, I was not able to edit directly because it was throwing an error saying that can't assign value to read-only object. So, after searching on stackoverflow, I found this AG-Grid: Cannot update field in Grid as it is read only.
So, I'm just trying to use this valueSetter as suggested in the post in the following way:-
this.columnDefs = Object.assign([], this.columnDefs);
console.log('coldDef init ', this.columnDefs);
this.columnDefs = this.columnDefs.map(obj=>({
...obj,
valueSetter: (params:any) => {
console.log("##newValue##",params.newValue);
const paramsCopy = {...params.data}
paramsCopy[obj.field]=params.newValue;
console.log(params);
params.data=paramsCopy;
console.log(params);
return true;
}
}));
In the logs I can see the new value.
But, I can't see my new value on the grid. Am I missing something?
Please let me know if you need more details.
Thank you!!