Hi Team,
I am facing the below issue while editing a cell and discard the changes. I have edited a cell and without saving clicked on Discard changes. We will be able to see the old value but if i click on the cell, discarded value is populated. I could reproduce this issue in igx-grid sample stackblitz. I could see the cell.editValue is having discarded value and is populated onEdit. Kindly let me know the fix for this issue.
Please find the steps to reproduce the issue.
Stackblitz - https://stackblitz.com/edit/angular-ijtpog
Thanks,
Vijay V
Hello Vijay,
Thank you for posting into our community!
I have been looking into your question and after an investigation I have determined that this behavior is due to the built-in validation service that sets the last edit value for the cell. Additionally, I have noticed that when “discarding the changes” you are setting the data property of the IgxGrid rather than updating/reverting the applied changes and as mentioned in our Validation triggers section here, validation will not trigger for records that have not been edited via user input or via the editing API, thus when entering edit mode for the same cell it displays the previous edit value.
Having this in mind, an approach I could suggest is using the IgxGridValidationService clear method after setting the data.
This could look similar to the following:
public setData() { this.grid.data = DATA2; this.grid.validation.clear(); }
Here could be found a small sample demonstrating this approach.
Additionally, if you require a functionality where the applied changes could be discarded, I recommend using batch editing as it allows every single modification of each cell to be preserved separately and undo/redo operations are available on cell level. More detailed information along with code snippets and samples could be found in our Batch Editing and Transactions topic here.
Please let me know if you need any further assistance regarding this matter.
Looking forward to your reply.
Sincerely,Riva IvanovaAssociate Software Developer
Hi,
In Angular 9 it is working fine but once we upgraded to Angular 14 we are facing this issue. We are using paid package "@infragistics/igniteui-angular": "^14.2.17" version. Based on our requirement we are not preferring batch edit. Kindly let us know if this issue will be addressed in future.
Thank you for following up!
I apologize if the provided sample was not an accurate demonstration of what you are trying to achieve. Having this in mind, I have modified the provided by you sample using Ignite UI for Angular version 14.2.x and included the previously suggested approach at the end of the custom preparation() method, i.e., at line 77.
The result is the same as previously mentioned and when editing a cell, clicking the reset button, and then entering edit mode for the same cell, the accurate edit value is displayed.
Here could be found the modified sample for your reference.
Additionally, in order for a similar solution to be provided out of the box, what I would suggest is logging this behavior in our GitHub repository here. This will give you the opportunity to directly communicate with our development team regarding this matter and get notifications whenever new information is available.
In the meantime, having in mind that the abovementioned approach works for both samples and versions 14.2.x and 15.0.x, I would suggest considering using the IgxGridValidationService clear method after setting the data.
Sincerely, Riva Ivanova Associate Software Developer