Designer: Enable/Disable ribbon/contextMenu items dinamically

Posted by: cristian.pilon on 18 January 2021, 2:53 pm EST

    • Post Options:
    • Link

    Posted 18 January 2021, 2:53 pm EST - Updated 3 October 2022, 10:01 am EST

    Hi GrapeCity team.,

    We recently bought a license for SpreadJS Designer 14 and we were looking for a way to enable/disable buttons and elements in the ribbon and context menu. We achieved that by manipulating a variable called _config inside the designer object:

    We were able to change enableContext and visualContext of custom commandMaps inside that object and the changes are reflected in the application.

    However, that looks like a private variable and we are almost sure that it is not the correct way to work with commands. Could you please let us know what is the correct way to do it?

    Thanks.

  • Posted 19 January 2021, 5:34 am EST

    Hi,

    Changing the config is the recommended way for manipulating the designer component but instead of changing the private config, You may change the default config as per your need and then use the setCofig method for updating the Designer. Please refer to the following code snippet and let us know if you face any issues.

    
    let defaultConfig =  GC.Spread.Sheets.Designer.DefaultConfig;
    //change the config as per your need
    designer.setConfig(defaultConfig);
    
    

    Regards

    Avinash

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels