您好,可以参考附件中的demo:
- let designerConfig = GC.Spread.Sheets.Designer.DefaultConfig;
- let customerRibbon = {
- "id": "operate",
- "text": "操作",
- "buttonGroups": [
- {
- "label": "文件操作",
- "thumbnailClass": "ribbon-thumbnail-spreadsettings",
- direction: "vertical",
- "commandGroup": {
- "children": [
- {
- command: "c1",
- type: "dropdown",
- children:['c2']
- }
- ]
- }
- },
- ]
- };
- let ribbonFileCommands = {
- "c1": {
- direction: "horizontal",
- iconClass: "ribbon-control-dropdown-mergecenter",
- text: "父级",
- commandName: "c1",
- execute: async function (context, propertyName) {
- console.log('parent')
- },
- },
- 'c2':{
- iconClass: "ribbon-control-dropdown-mergecenter",
- text:'子级',
- commandName:'c2',
- execute: async function (context, propertyName) {
- console.log('children')
- },
- }
- }
- designerConfig.commandMap = {};
- Object.assign(designerConfig.commandMap, ribbonFileCommands);
- designerConfig.ribbon.unshift(customerRibbon);
- designer.setConfig(designerConfig);
复制代码 结果如下动图所示:
|