找回密码
 立即注册

QQ登录

只需一步,快速开始

Joestar.Xu SpreadJS 开发认证

超级版主

38

主题

6638

帖子

8682

积分

超级版主

Rank: 8Rank: 8

积分
8682

SpreadJS 认证SpreadJS 高级认证

Joestar.Xu SpreadJS 开发认证
超级版主   /  发表于:2023-12-28 15:31  /   查看:593  /  回复:0
本帖最后由 AlexZ 于 2024-1-3 15:45 编辑

很多客户在使用SpreadJS的自定义Command时会发现一个问题,在撤销时没有显示名称,取而代之的是一片空白,如下图所示:


image.png82691039.png

这样会让用户不知道自己做了什么操作,为了解决这样的问题,我们需要再重写redoList和undoList这两个指令:

例如,当我有一个自定义Command的变量名为setBackColor:


  1. let undoList = GC.Spread.Sheets.Designer.getCommand(GC.Spread.Sheets.Designer.CommandNames.UndoList);
  2. let redoList = GC.Spread.Sheets.Designer.getCommand(GC.Spread.Sheets.Designer.CommandNames.RedoList);
  3. redoList.commandMap['changeBackColor'] = '哈哈哈哈哈哈';
  4. undoList.commandMap['changeBackColor'] = '哈哈哈哈哈哈';

  5. [color=#e2dace]customConfig.commandMap = {};[/color]
  6. [color=#e2dace]customConfig.commandMap[GC.Spread.Sheets.Designer.CommandNames.UndoList] = undoList;[/color]
  7. [color=#e2dace]customConfig.commandMap[GC.Spread.Sheets.Designer.CommandNames.RedoList] = redoList;
复制代码



在上述代码中,我们将changeBackColor在撤销重做栈中的名称修改为了“哈哈哈哈哈哈”。


效果如下:



image.png617269286.png
SpreadJS 17.0.8 | GcExcel 7.1.0 已发布~

0 个回复

您需要登录后才可以回帖 登录 | 立即注册
返回顶部