您好,请参考以下代码:
- window.onload = function () {
- let designerConfig = JSON.parse(
- JSON.stringify(GC.Spread.Sheets.Designer.DefaultConfig)
- );
- designerConfig.commandMap = {
- menu: {
- text: "菜单",
- title: "菜单",
- bigButton: "=ribbonHeight>toolbarHeight",
- commandName: "menu",
- direction: '=IF(ribbonHeight<toolbarHeight,"horizontal","vertical")',
- dropdownListItemType: "menuitemradio",
- // enableContext: "",
- iconClass: "ribbon-button-formattable",
- },
- list: {
- commandName: "list",
- // enableContext: "",
- execute(context, propertyName, checked) {
- console.log("execute");
- console.log(context);
- console.log(propertyName);
- console.log(checked);
- },
- getState(context, propertyName) {
- console.log("getState");
- console.log(context);
- console.log(propertyName);
- },
- listContent: [
- {
- commandName: "list",
- groupItems: [
- {
- iconClass: "table-format-light0",
- iconHeight: 48,
- iconWidth: 64,
- tip: "Item1",
- value: "light0",
- },
- {
- iconClass: "table-format-light0",
- iconHeight: 48,
- iconWidth: 64,
- tip: "Item1",
- value: "light0",
- },
- {
- iconClass: "table-format-light1",
- iconHeight: 48,
- iconWidth: 64,
- tip: "Item1",
- value: "light0",
- },
- {
- iconClass: "table-format-light1",
- iconHeight: 48,
- iconWidth: 64,
- tip: "Item1",
- value: "light0",
- },
- {
- iconClass: "table-format-light2",
- iconHeight: 48,
- iconWidth: 64,
- tip: "Item1",
- value: "light0",
- },
- {
- iconClass: "table-format-light2",
- iconHeight: 48,
- iconWidth: 64,
- tip: "Item1",
- value: "light0",
- },
- {
- iconClass: "table-format-light3",
- iconHeight: 48,
- iconWidth: 64,
- tip: "Item1",
- value: "light0",
- },
- {
- iconClass: "table-format-light3",
- iconHeight: 48,
- iconWidth: 64,
- tip: "Item1",
- value: "light0",
- },
- ],
- groupName: "List One",
- wrap: false,
- },
- ],
- maxWidth: 550,
- type: "listContent",
- },
- };
- designerConfig.ribbon[0].buttonGroups.push({
- label: "测试",
- thumbnailClass: "ribbon-thumbnail-styles",
- commandGroup: {
- children: [
- {
- children: ["list"],
- command: "menu",
- dropdownMaxWidth: 550,
- type: "dropdown",
- },
- ],
- },
- });
- let designer = new GC.Spread.Sheets.Designer.Designer(
- "gc-designer-container",
- designerConfig
- );
- let spread = designer.getWorkbook();
-
- let sheet = spread.getActiveSheet();
- };
复制代码 |