您好, 请问您是想动态改变设计器上自定义工具栏的文字和图标吗?有一部分工具栏是带值的,比如字体、字号等,getState是用于获取这个值,而不是去动态设置文字和图标的。要动态设置,只能重新给designer去setConfig,暂时没有其他办法了,您可以试试
- let customState = 2
- let config = GC.Spread.Sheets.Designer.DefaultConfig
- config.commandMap = {
- Welcome: {
- title: "Welcome",
- text: "Welcome China",
- iconClass: "ribbon-button-welcome",
- bigButton: "true",
- commandName: "Welcome",
- execute: function (context, propertyName, fontItalicChecked) {
- refreshDesigner(context)
- }
- }
- }
- config.ribbon[0].buttonGroups.unshift({
- "label": "NewDesigner",
- "thumbnailClass": "welcome",
- "commandGroup": {
- "children": [
- {
- "direction": "vertical",
- "commands": [
- "Welcome"
- ]
- }
- ]
- }
- });
- designer.setConfig(config)
- function refreshDesigner(designer) {
- if (customState == 1) {
- config.commandMap = {
- Welcome: {
- title: "Welcome",
- text: "Welcome China",
- iconClass: "ribbon-button-welcome",
- bigButton: "true",
- commandName: "Welcome",
- execute: function (context, propertyName, fontItalicChecked) {
- refreshDesigner(context)
- }
- }
- }
- customState = 2
- } else if (customState == 2) {
- config.commandMap = {
- Welcome: {
- title: "Welcome",
- text: "Welcome US",
- iconClass: "ribbon-button-welcome-us",
- bigButton: "true",
- commandName: "Welcome",
- execute: function (context, propertyName, fontItalicChecked) {
- refreshDesigner(context)
- }
- }
- }
-
- customState = 1
- }
- designer.setConfig(config)
- }
复制代码 |