已经找到了相应的方法了 加上这个就好了 spreadAll.options.allowUndo = true; 顺便给下ctrol+d的代码- function ctrold() {
- // 设置允许撤销操作
- spreadAll.options.allowUndo = true;
- spreadAll.commandManager().register("ctrol+d",
- {
- canUndo: true,
- execute: function (context, options, isUndo) {
- var Commands = GC.Spread.Sheets.Commands;
- // 在此加cmd名称
- options.cmd = "ctrol+d";
- if (isUndo) { Commands.undoTransaction(context, options);
- return true; }else{
- alert("ctrol+d");
- // 开始事务
- Commands.startTransaction(context, options);
- var sheet = spreadAll.getActiveSheet();
- var selects = sheet.getSelections()[0];
- if(selects.rowCount==1){
- sheet.copyTo(selects.row-1,selects.col,selects.row,selects.col,selects.rowCount,selects.colCount,GC.Spread.Sheets.CopyToOptions.value);
- }else if(selects.rowCount>1){
- for(var i = 0;i<selects.rowCount;i++){
- sheet.copyTo(selects.row,selects.col,selects.row+i,selects.col,1,selects.colCount,GC.Spread.Sheets.CopyToOptions.value);
- }
- }
- // 结束事务
- Commands.endTransaction(context, options);
- return true;
- }
- }
- });
- spreadAll.commandManager().setShortcutKey(
- "ctrol+d", 68, true, false, false, false
- );
- }
复制代码 |