Execute custom designer ribbon commands

Posted by: m.holland-moritz on 3 May 2022, 8:04 pm EST

    • Post Options:
    • Link

    Posted 3 May 2022, 8:04 pm EST

    Hey Team,

    i have set several custom commands for my app. Now i have the problem after some routine i want to execute a set command without needing the client click on the followup-button.

    I tried with clicking it via queryselector, which worked perfectly fine, but i realized that if the tab has never opened the button doesn’t exist at all, which could cause some issues.

    So now i though about executing the command via the command i set in commandmap.

    var spread = GC.Spread.Sheets.findControl(document.getElementById("ss"));
    spread.commandManager().execute({cmd: "dataCheck"})
    

    Nothing happened, since it doesn’t exist in there.

    So is there a way to execute this codevise:

    var checkData = {
                title: window.dict.com_REM_Ti[language],
                text: window.dict.com_REM_Te[language],
                iconClass: "cmdCheckData",
                bigButton: true,
                commandName: "checkData",
                execute: async (context, propertyName) => {
    
    		//Stuff i want to execute 
    
    
                }
            }
    //config for init spread
    config.commandmap.push(checkData)
    
    
    var ribbonDC = {
            "id": "RegEx",
            "text": "Datacheck",
            "buttonGroups": [
                {
                    "label": window.dict.conf_test_REM_la[language],
                    "thumbnailClass": "",
                    "commandGroup": {
                        "children": [
                            {
                                "commands": [
                                    "assignFieldToColumn",
                                    "checkData",
                                    "showError"
                                ]
                            }
                        ]
                    }
                }
    	]
    }
    config.ribbon.unshift(ribbonDC)
    

    I hope u can help me. If you need some more information, just tell me.

    Regards

    Maik-

  • Posted 4 May 2022, 5:22 am EST

    Hi Maik,

    First you need to register the command to the command manager and then you can execute the command by using spread.commandManager().execute() method.

    spread.commandManager().register("checkData", config.commandMap["checkData"]);
    

    For example, you can refer to the following sample that I have created for you: https://jscodemine.grapecity.com/share/dSP9CUMUNkir_YXwIvd-ig/

    register method: https://www.grapecity.com/spreadjs/docs/latest/online/SpreadJS~GC.Spread.Commands.CommandManager~register.html

    Please let us know if you need further assistance on this query. We would be happy to help you.

    Regards

    Ankit

  • Posted 10 May 2022, 5:00 pm EST

    Hey Ankit,

    thanks for the help! That worked fine.

    Regards

    Maik

Need extra support?

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

Learn More

Forum Channels