您好,可以参考下面的代码
- var config = GC.Spread.Sheets.Designer.DefaultConfig;
- config.commandMap = {
- Welcome: {
- title: "Welcome",
- text: "Welcome",
- iconClass: "ribbon-button-welcome",
- type:"checkbox",
- bigButton: "true",
- commandName: "Welcome",
- execute: function (context, propertyName, checked) {
- designer.setData('flag', checked);
- },
- getState: function (context, prop) {
- return designer.getData('flag');
- }
- }
- }
- config.ribbon[0].buttonGroups.unshift({
- "label": "NewDesigner",
- "thumbnailClass": "welcome",
- "commandGroup": {
- "children": [
- {
- "direction": "vertical",
- "commands": [
- "Welcome"
- ]
- }
- ]
- }
- });
- var designer = new GC.Spread.Sheets.Designer.Designer(document.getElementById("gc-designer-container"), config);
复制代码 核心代码是
- execute: function (context, propertyName, checked) {
- designer.setData('flag', checked);
- },
- getState: function (context, prop) {
- return designer.getData('flag');
- }
复制代码 当选择图表后,发现dom元素会添加check属性,如下图
所以添加相应的css样式即可:
- .ribbon-button-welcome {
- background:url('./1.png');
- background-image:background-size: 35px 35px;
- }
- .gc-ribbon-bar .ribbon-button-checkbox.big-button[checked="true"] .ribbon-button-item-icon ,
- .gc-ribbon-bar .ribbon-button-checkbox.gc-icon-text-both[checked="true"] .ribbon-button-item-icon{
- background:url('./2.png');
- background-size: 35px 35px;
- }
复制代码 效果如下:
|