Disable/Enable ribbon paste options when change active sheet

Posted by: nhan.thanh.nguyen on 25 April 2023, 12:07 am EST

  • Posted 25 April 2023, 12:07 am EST - Updated 25 April 2023, 12:13 am EST

    Hi teams,

    I want to disable/enable some paste options (formatting, values formatting, formulas formatting) on ribbon menu when I change the active sheet. I have used setConfig method and then refresh designer but it’s not working.

    In my case, if sheet is sheet 1 it will disable 3 paste options as I mentioned above. If we change to another sheet, it will enable again these options.



    I’m using spreadjs version 14.0.4 with reactjs

    I’m looking to hearing from you,

    Thanks and Best Regars,

    Nhan Nguyen

  • Posted 26 April 2023, 6:34 am EST

    Hello Nhan,

    You can enable/disable paste options in different sheets of the spread. You need to get “pasteFormatting”, “pasteValuesAndFormatting” and “pasteFormulasAndFormatting” commands’ object of paste options and add a custom variable in the enableContext property of the commands. The enableContext property is used to specify whether a command(option) will be enabled or disabled based on an expressions of variables.

    The custom variable will be used to determine whether the paste options should be enabled/disabled in a particular sheet. You can define a custom variable using designer.setData() method. You can change the value of custom variable inside the event handler function of ActiveSheetChanged event. This way, paste options will be disabled for particular sheet and enabled for other sheets.

    Please refer to the attached sample for further understanding. Let us know if you still face any issues.

    Doc references:

    ICommand interface: https://www.grapecity.com/spreadjs/api/designer/interfaces/GC.Spread.Sheets.Designer.ICommand#interface-icommand

    designer.setData(): https://www.grapecity.com/spreadjs/api/v16/designer/classes/GC.Spread.Sheets.Designer.Designer#setdata

    ActiveSheetChanged event: https://www.grapecity.com/spreadjs/api/v15/classes/GC.Spread.Sheets.Events#activesheetchanged

    Regards,

    Ankit

    Sample: spread-designer-14-react.zip

Need extra support?

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

Learn More

Forum Channels