tables.addFromDataSource 不能事务撤回
本帖最后由 Wilson.Zhang 于 2024-9-25 16:14 编辑产品:SpreadJS
版本:17.1.5
调研编号:SJS-26442
Last Rview:2024-09-25
当前进展:已在17.1.6版本修复。
tables.addFromDataSource 不能事务撤回,能解决吗
您好!需要您详细介绍下问题场景。 Wilson.Zhang 发表于 2024-9-10 18:12
您好!需要您详细介绍下问题场景。
sheet.tables.addFromDataSource(tableName, r, c, source, spreadNS.Tables.TableThemes.medium15); 这种方式生成一个table,放在撤回事务里,无法撤回
您的意思指的是执行了这句代码之后,Ctrl+Z无法撤回是吗? Clark.Pan 发表于 2024-9-11 13:49
您的意思指的是执行了这句代码之后,Ctrl+Z无法撤回是吗?
bindEventTransaction(event, param1, param2, param3, param4) {
let that = this;
let transactionName = 'tran_' + this.generateUniqueId();
// 撤回增加事务
let command = {
canUndo: true,
execute: function (spread, options, isUndo) {
let Commands = GC.Spread.Sheets.Commands;
options.cmd = transactionName;
if (isUndo) {
Commands.undoTransaction(spread, options);
return true;
} else {
Commands.startTransaction(spread, options);
spread.suspendPaint();
// 执行excel具体操作
sheet.tables.addFromDataSource(tableName, r, c, source, spreadNS.Tables.TableThemes.medium15);
spread.resumePaint();
Commands.endTransaction(spread, options);
return true;
}
}
};
let commandManager = that.spread.commandManager();
let sheetName = that.spread.getSheet(0).name();
if (sheetName == "Evaluation Version") {
sheetName = that.spread.getSheet(1).name();
}
commandManager.register(transactionName, command);
commandManager.execute({
cmd: transactionName,
sheetName: sheetName, // 事务必填sheetName
});
}
这样, 无法通过undoManager.undo();撤回, 我试了一下这样做是可以撤回的
spread.undoManager().undo()
undoManager是一个方法,undoManager后应该有一个括号,你是不是没有加括号 Clark.Pan 发表于 2024-9-11 16:22
我试了一下这样做是可以撤回的
spread.undoManager().undo()
undoManager是一个方法,undoManager后应该 ...
undo() {
let undoManager = this.spread.undoManager();
undoManager.undo();
},
xin() {
let that = this;
let transactionName = 'tran_' + this.generateUniqueId();
// 撤回增加事务
let command = {
canUndo: true,
execute: function (spread, options, isUndo) {
let Commands = GC.Spread.Sheets.Commands;
options.cmd = transactionName;
if (isUndo) {
Commands.undoTransaction(spread, options);
return true;
} else {
Commands.startTransaction(spread, options);
spread.suspendPaint();
// 执行excel具体操作
let source = [
{ "a": "a", "a": '', },
]
let spreadNS = GC.Spread.Sheets;
let sheet = that.spread.getActiveSheet();
let tableName = 'table_' + that.generateUniqueId();
let table = sheet.tables.addFromDataSource(tableName, 1, 1, source, spreadNS.Tables.TableThemes.medium15);
spread.resumePaint();
Commands.endTransaction(spread, options);
return true;
}
}
};
let commandManager = that.spread.commandManager();
let sheetName = that.spread.getSheet(0).name();
if (sheetName == "Evaluation Version") {
sheetName = that.spread.getSheet(1).name();
}
commandManager.register(transactionName, command);
commandManager.execute({
cmd: transactionName,
sheetName: sheetName, // 事务必填sheetName
});
let redoStack = this.spread.undoManager().getRedoStack();
let undoStack = this.spread.undoManager().getUndoStack();
console.log(redoStack, "保留栈")
console.log(undoStack, "撤销栈")
},
版本@grapecity-software/spread-sheets-vue": "17.1.0", 确实撤回不了 V17.1.0以后的版本我发现确实撤回不了了,之前的版本还是可以的。我这边会调查一下原因。如果是产品问题会尽快修复 您好!该问题已在17.1.6版本修复,17.1.6版本也已发布,您可以升级版本后使用。
{:5_110:}
页:
[1]