Manipulate the undo stack

Posted by: achort on 15 November 2021, 4:42 am EST

  • Posted 15 November 2021, 4:42 am EST

    Hi,

    I have a question regarding the undo/redo stack.
    Some context: we are adding multiple sheets to a single SpreadJs instance but only showing one at a time. That is: we hide all sheets except the current one, users can change the current sheet through external control.

    I was wondering if there is a way to filter the undo/redo stack to only show the items concerning a particular sheet or manipulate it in any way.

    All we have found so far is that you can clear it.

    Thank you.
  • Replied 15 November 2021, 9:27 pm EST

    Hey,

    getUndoStack Method and getRedoStack Method returns an object that includes sheetName. You can filter the undoStack/redoStack(stack returned being array) by sheetName.



    getRedoStack(): https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Commands.UndoManager~getRedoStack.html



    getUndoStack(): https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Commands.UndoManager~getUndoStack.html



    Thanks.
  • Replied 17 November 2021, 6:30 am EST

    Hi,

    Yes, I have inspected the UndoManager class and noticed those two methods.
    However, I don't see any method to modify the stacks (ie: setUndoStack and setRedoStack).

    Is there a way to remove a particular item from the stack so it does not appear in the undo menu of the Designer?

    Thank you.
  • Marked as Answer

    Replied 17 November 2021, 4:43 pm EST

    Hi,

    We are sorry but we could change the built-in undo stack. We could only clear the undo stack using the clear method. We are sorry for the inconvenience.

    API references:

    clear: https://www.grapecity.com/spreadjs/docs/v14/online/SpreadJS~GC.Spread.Commands.UndoManager~clear.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