Closed Thoemmy closed 1 week ago
My current workaround is as following:
Custom Revogrid comp wrapper
ngOnChanges(changes: SimpleChanges): void {
this.newSource = _.cloneDeep(changes['source'].currentValue);
}
ngOnInit(): void {
this.newSource = _.cloneDeep(this.source);
}
But i think there must be a other way ...
I'll check soon, ty @Thoemmy !
Hi @Thoemmy,
Thank you for sharing your example. After reviewing it (next time better provide github repo to clone, easier to catch), I noticed that the issue seems to stem from the following line:
this.newSource = _.cloneDeep(changes['source'].currentValue);
It looks like changes['source'].currentValue
is a readonly value, which is likely an @Input()
property. Attempting to modify a readonly value directly (or even indirectly via deep cloning) breaks Angular's reactivity system. For example, trying something like changes['source'].currentValue[0] = {}
would result in the same error because @Input()
properties should not be modified directly.
There are several ways to handle this:
I highly recommend reviewing the grid's data synchronization documentation: Data Sync Guide. This will give you a clearer understanding of how to properly manage the grid's data.
Decide on Data Editing Strategy: Based on the approach you choose after reading the documentation, you’ll need to decide whether:
Avoid cloneDeep
:
Instead of using _.cloneDeep
, you can use a simple array spread to create a new reference without deep cloning:
this.newSource = [...changes['source'].currentValue];
This ensures that newSource
is updated, but keep in mind that this will not affect the original source array, meaning changes will only apply to newSource
and not the original data.
Let me know if you need further clarification or assistance with implementing this approach!
Cheers.
Describe the issue
My config for the angular app is looking as following, if i load the dev environment setup with production = false then i receive an error when i try to change some values in the revogrid table, but if production=true then i do not receive any errors.
By mistake, the production mode was permanently switched on, which also meant that the strict checks by angular were not active.
I tried to add a "cloned" array to the source of revogrid but same situation (used spread operator), i did not tried it with loadash cloneDeep cause it should be possible without i guess.
Would be great if you could give me some suggestions which i can check or test.
Angular Config:
Error message after editing a cell in revogrid:
If i enable prod mode this error do not occur, this is really strange.