Posted 26 August 2025, 6:37 am EST - Updated 26 August 2025, 6:53 am EST
Hi team , I am trying to implement a custom undo redo functionality for Gridlines , but the undo is not working , supposedly the action is not getting pushed to the undo stack , since on undo its not executing the function .
Is Gridline operation undoable ?
Following is the code snippet
var setGridLines = {
canUndo: true,
execute: function (context, options, isUndo) {
debugger;
let sheet = context.getSheetFromName(options.sheetName);
let Commands = GC.Spread.Sheets.Commands;
var formatType = isUndo ? "undo" : options.formatType;
if (isUndo) {
Commands.undoTransaction(context, options);
} else {
Commands.startTransaction(context, options);
// Get current gridline options from the sheet obtained from the context
let currentGridlineOptions = sheet.options.gridline;
// Create a new gridline object with toggled values to ensure change tracking
sheet.options.gridline = {
showVerticalGridline: !currentGridlineOptions.showVerticalGridline,
showHorizontalGridline: !currentGridlineOptions.showHorizontalGridline,
color: currentGridlineOptions.color
};
Commands.endTransaction(context, options);
}
return true;
}
};