Events to detect changes

Posted by: srinivas.suravarapu on 2 April 2025, 3:48 am EST

    • Post Options:
    • Link

    Posted 2 April 2025, 3:48 am EST

    Hi

    We are using the event

    commandManager.addListener(‘appListener’, (args) => {

    // do something if args.command.cmd is something specific

    });

    Is there a list of commands that pertain to formatting changes and / or data changes ? that we can subscribe to , I guess for data changes getDirtyCells and getDirtyRows will do the trick, (not sure if these methods return cells if the changes are purely formatting changes). This is really a way of detecting that the spreadsheet needs to be saved for us, and I am not sure why this is not available like a dirtyFlag on each sheet

  • Posted 3 April 2025, 4:32 am EST

    Hi,

    The data changes in the SpreadJS can be captured using the command editCell. Please refer to the code snippet below that illustrates how to capture the data changes:

    commandManager.addListener("appListener", (args) => {
      if (args.command.cmd === "editCell") {
        console.log("Data Changes");
      }
    });

    Additionally, to capture the formatting changes, you can listen to the following commands-

    Designer.setFormatter
    Designer.setFormatDialog

    Please refer to the code snippet below, which listens to these commands:

    commandManager.addListener("appListener", (args) => {
      switch (args.command.cmd) {
        case "Designer.setFormatter":
        case "Designer.setFormatDialog":
          console.log("Formatting changes");
        }
      }
    });

    In case you need to listen to all the style changes, it is possible by checking if the changes in the sheet are style-changes as follows:

    commandManager.addListener("appListener", (args) => {
      const sheetName = args.command.sheetName;
      if (
        args.command[`changes${sheetName}`] &&
        args.command[`changes${sheetName}`][0][0] === "style-changes"
      ) {
        console.log("Style changes");
      }
    });

    You can further refer to the attached sample that uses the above code snippets and listens to all the data, formatting, and style changes (see below).

    Please feel free to reach out if you require any additional guidance.

    Regards,

    Ankit

    ListenChanges (1).zip

  • Posted 4 April 2025, 6:30 am EST

    Thank you I will try that

    I thought I would get a email notification from this thread but didnt

  • Posted 4 April 2025, 8:00 am EST

    Hi,

    You’re welcome! Let us know how it goes when you try the code.

    About the email notification — could you please check if it ended up in your spam or junk folder? Sometimes it gets filtered there.

    Let us know if you require any additional guidance.

    Best Regards,

  • Posted 15 April 2025, 4:53 am EST

    This worked out fine, I had to tweak what we listen to as expected

Need extra support?

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

Learn More

Forum Channels