[DESIGNER] How to disable a context menu item or ribbon button conditionally?

Posted by: ffrey on 16 December 2020, 1:35 am EST

    • Post Options:
    • Link

    Posted 16 December 2020, 1:35 am EST

    Hello, client I work for has purchased the designer and we are going to add some additional context menu items as well as buttons in the ribbon. I have followed the documentation and they display perfectly, but now I need to disable (in ribbon) and hide (in context menu) the items, is there a way to do so?

    Documentation shows how to add but not how to create conditions to hide or disable them.

    https://www.grapecity.com/spreadjs/docs/v14/online/add_context_menu_item.html

    https://www.grapecity.com/spreadjs/docs/v14/online/add_context_menu_item.html

    May I ask you to provide some examples?

    thanks in advance, Fernando

  • Posted 16 December 2020, 11:43 pm EST

    Hi,

    You may use visibleContext property to hide the element from the designer context menu. Please refer to the following code snippet and attached sample that demonstrates the same.

    
      constructor(private spinner: NgxSpinnerService) {
        (config as any).commandMap =  this.element;
      }
    
    element = {
        "designer.insertSignature": {
            text: "Insert Signature",
            commandName: "designer.insertSignature",
            visibleContext: "ClickRowHeader",
            execute:
            // execute_InsertSignature, following just a simple demo code snippet
            () =>{
                console.log("Insert Signature");
            }
        }
      }
     changeHappend(e){
    if(e.target.checked)
    this.element["designer.insertSignature"].visibleContext = "none"
    else
    this.element["designer.insertSignature"].visibleContext = "ClickRowHeader"
    
     }
    
    

    Regards

    Avinash

    AngularTestApp.zip

Need extra support?

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

Learn More

Forum Channels