Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
105
Cell onEdit populating old value after Discard Issue
posted

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.

  1. Edit a particular cell and click on Enter.
  2. Discard the changes.
  3. We will be able to see the old value.
  4. Click on that cell for edit, the discarded value is populated.

Stackblitz - https://stackblitz.com/edit/angular-ijtpog

Thanks,

Vijay V

Parents
  • 700
    Offline posted

    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 Ivanova
    Associate Software Developer

Reply Children