Undo and getDirtyCells()

Posted by: developers on 25 May 2021, 8:01 pm EST

    • Post Options:
    • Link

    Posted 25 May 2021, 8:01 pm EST

    Hi,

    we’re encountering a problem using the undo with some worksheets.

    We have a cell with a value (e.g. A1 = 100) and other two cells with a value based on the value of the first cell (e.g. B1 = 200 and C1 = 300).

    If we change the value of the first cell (e.g. A1 = 50) we see the changes on the other two cells (e.g. B1 = 100 and C1 = 150), we get the new value from the ValueChanged() event on the first cell and with the getDirtyCells() method we obtain the values from the other two cells.

    If we make an undo, we get back to the original values (100, 200, 300), we get the value of the first cell from the ValueChanged() event, but we are not able to get the values of the other two cells because the getDirtyCells() method return an empty array.

    Is it possible to handle the undo in order to get all the changes in our worksheet?

    Best regards,

    Ciro

  • Posted 26 May 2021, 7:11 pm EST

    Hi Ciro,

    This is by design This is by design, that should not be dirty. The internal storage has been restored by the undo action. If you need to know what other cells got update you may use the getDependents method inside the CellChanged event. Pease refer to the following code snippet and let me know if you face any issues.

    
     sheet.bind(GC.Spread.Sheets.Events.CellChanged, (e, args) => {
        if (args.propertyName === "value" && args.isUndo) {
          console.log(
            "Thease cells are also got restored on undo",
            args.sheet.getDependents(args.row, args.col)
          );
        }
      });
    
    

    API references:

    getDependents: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Sheets.Worksheet~getDependents.html

    regards

    Avinash

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels