Detect Undo/Redo action on cell edited

Posted by: davide.vago on 23 November 2019, 7:07 am EST

  • Posted 23 November 2019, 7:07 am EST

    Good morning/evening

    I’m currently working on a custom functionality which needs to be triggered every time the user edit the cells (value/formulas), therefore I’m using events from SpreadJS documentation (EditChange, EditEnded) in order to track and store what the user does.

    Unfortunately, I don’t have any feedback once the user insert a value to a cell and press CTRL/CMD + Z to undo the action.

    The API for row/column change has an isUndo flag but that’s not useful for my case.

    Please do let me know if you have any suggestion

  • Posted 25 November 2019, 7:03 am EST

    Hi Davide,

    You may handle the “CellChanged” event to detect cell value changes even during undo operation. Please refer to the following code snippet:

    spread.bind(GC.Spread.Sheets.Events.CellChanged, function(e, args) {
        if (args.propertyName === "value") {
          // value is changed
          console.log(args.oldValue, args.newValue);
        }
      });
    

    Regards

  • Posted 25 November 2019, 8:19 am EST

    Good morning/afternoon Sharad

    The event CellChanged doesn’t tell me if the value (newValue) is an Undo, so I don’t actually know how to distinguish between: “ok this is an update of the cell” or “this is actually the undo event, meaning the newValue is exactly the same as the previous-previous value.”

  • Posted 26 November 2019, 6:45 am EST

    Hi Davide,

    Yes, you are right, CellChanged event doesn’t provide us any info regarding if the action is an undo operation but I’m unable to understand the use case that why you need to handle value change differently for Undo event from edit event. Could you please explain some about your use case?

    Thank you

  • Posted 26 November 2019, 10:33 am EST

    Good morning/afternoon.

    I need to understand when a user does an undo within cells because what I’m creating need to create a diff of all the changes made by the user and the initial underlying data. For this reason I would like to have something similar to what the library already has on row/column changes events (a flag that says: isUndo: true/false)

    Looking forward to hearing from you

    Thanks for the support

  • Posted 27 November 2019, 5:15 am EST

    Hi Davide,

    Thank you for the additional info. We have forwarded it to the dev team and will let you know about any updates regarding the issue. The internal tracking ID for the issue is SJS-2680.

    In the meantime, you may override the undo command as demonstrated the following sample to distinguish the undo operation from normal operation:

    https://codesandbox.io/s/spread-js-starter-mh39r

    Regards

  • Posted 7 February 2020, 4:36 am EST

    Hi Davide,

    This feature has been implemented in v13.0.2. Now CellChanged event args have an additional property named isUndo to distinguish between normal operation and Undo operation. Please update to the latest build and let us know if the issue persists for you.

    Regards

    Sharad

  • Posted 14 April 2020, 2:29 am EST

    Hi,

    ICellChangedEventArgs could fixed?

    export interface ICellChangedEventArgs{

    sheet: GC.Spread.Sheets.Worksheet;

    sheetName: string;

    row: number;

    col: number;

    sheetArea: SheetArea;

    propertyName: string;

    oldValue: any;

    newValue: any;

    }

  • Posted 17 April 2020, 9:54 am EST

    Hi,

    We have confirmed that the info for the isUndo property is missing from the ICellChangedEventArgs interface and hence we have forwarded it to the concerned team(INternal tracking ID: SJS-4156). We will let you know about any updates regards the same.

    Till then you may use the isUndo property as follows:

    spread.bind(GC.Spread.Sheets.Events.CellChanged, (e: any, args: any) => {
          if(args.isUndo){
            // do something
          }
        });
    

    Regards

    Sharad

  • Posted 18 May 2020, 3:20 am EST

    Hi,

    This issue is now fixed in our latest hotfix 13.1.1. Please update to the latest version and let us know if the issue persists for you. You may get the latest build from npm or download using the following link:

    http://cdn.grapecity.com/spreadjs/13.1.1/Files/SpreadJS.Release.13.1.1.zip

    Regards

Need extra support?

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

Learn More

Forum Channels