SpreadJS 15
SpreadJS Designer Component / Customizations / Enable or Disable Ribbon Elements
In This Topic
    Enable or Disable Ribbon Elements
    In This Topic

    Follow the below steps to disable the "Table" field button from the "INSERT" tab.

    1. Access the default configuration and identify the command associated with the "Table" button, in this case the "insertTable" command.

      JavaScript
      Copy Code
      // Configure Workbook and Worksheet
      var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"));
      var activeSheet = spread.getActiveSheet();
      
      // Access the default config
      var config = GC.Spread.Sheets.Designer.DefaultConfig;
      
      console.log(config);
      
      // Find the below snippet for "Table" button
      
      // "ribbon": [
      // {
      //  ...
      //
      //   "id": "insert",
      //   "text": "INSERT",
      //   "buttonGroups": [
      //     {
      //       "label": "Table",
      //       "thumbnailClass": "ribbon-thumbnail-table",
      //       "commandGroup": {
      //         "commands": [
      //           "insertTable"      // Associated command
      //         ]
      //       }
      //     }]
      // }]
      

    2. Apply getCommand method on the above command (insertTable) to identify its state expression.
      JavaScript
      Copy Code
      console.log(GC.Spread.Sheets.Designer.getCommand('insertTable'));
      
      // commandName: "insertTable"
      // enableContext: "AllowInsertTable  && !IsProtected"
      

    3. Set the above command to commandMap in your project and disable the respective state expression by setting the enableContext option.
      JavaScript
      Copy Code
      config.commandMap = {
          insertTable: {
              commandName: "insertTable",
              // To disable the Table button
              enableContext: "!AllowInsertTable" 
          }
      }
      

    4. Initialize the designer instance by passing "config" parameter for customizable configuration.
      JavaScript
      Copy Code
      var designer = new GC.Spread.Sheets.Designer.Designer(document.getElementById("designerHost"), config, spread);
      

    The below output will be generated: