Posted 26 October 2022, 9:02 am EST
Hi
I’m trying to implement the undo/redo like i saw in the documentation:
https://www.grapecity.com/spreadjs/docs/features/worksheet/undo
In your documentation example, for setting commands in the same undo/redo transaction i need to put them between “commands.startTransaction(context, options);” and “commands.endTransaction(context, options);”
in our system we have async flows, it means that i want to insert commands from before the async call and after it returns to the same transaction .
For example, i may want to put commands into transaction A through an async call, and while waiting for the call back add commands to transaction B in a different flow, when the async call return i want to add more commands to transaction A.
is it possible?
const cell : GC.Spread.Sheets.CellRange;
const cell2 : GC.Spread.Sheets.CellRange;
const command = {
canUndo: true,
execute: (context: GC.Spread.Sheets.Workbook, options: any, isUndo: boolean) => {
const commands = gcModule.Spread.Sheets.Commands;
if (isUndo) {
commands.undoTransaction(context, options);
return true;
} else {
commands.startTransaction(context, options);
cell.value("value")
setTimeout(() => {
cell2.value("value2")
}, 200)
commands.endTransaction(context, options);
return true;
}
},
};
const commandManager = gcModule.workbook.commandManager();
commandManager.register("id", command);
commandManager.execute({ cmd: "id", sheetName });
Thanks Lior
