Right-click custom menu

Tags: #<Tag:0x00007f8b25d34c78>

Hi, I want to create a new right-click menu option and then add the default option as a submenu, such as “row_above”, “row_below”, “col_left”, etc. Here is the code I write

`contextMenu:{
    items: {
        "edit_row_col": {
            name: "operation",
            submenu: {
                items: [
                    {key: "row_above", name:"add a row above"},
                    {key: "row_below", name:"add a row below"},
                    {key: "col_left", name:"add a left col"},
                    {key: "col_right", name:"add a right col"},
                ]
            }
        }    
    }
}`

But when I click, the browser prompts “Error: Menu command ‘row_below’ not exists.”

Hey @759603225

the structure of the submenu is slightly different. Here’s an example with a submenu https://jsfiddle.net/AMBudnik/2rdbyxng/

I saw on the official website that you can use the executeCommand() to execute predefined commands, can you provide some examples?

I had a chat with our programmer and to be honest the documentation lacks some description for this method. I would personally remove this method from the official API as it cannot be called/used directly after making a call to the contextMenu plugin. However I will test it out a bit more.

In the meanwhile, as I suppose you need to use one or more options from this list. Can you share more details? All those options should be available by accessing correct plugins.

Sure. I want to put all the predefined commands that add rows/columns and delete rows/columns in the same submenu, but I didn’t achieve the effect when I clicked. What else details do you need? Here is the code

`contextMenu: { 
                items: {
                    "edit_row_col": {
                        name: "operation",
                        submenu: {
                            items: [
                                {key: "row_above", name:'add a row above'},
                                {key: "row_below", name:'add a row below'},
                                {key: "col_left", name:'add a left col'},
                                {key: "col_right", name:'add a right col'},
                                {key: "remove_row", name: 'delete row'},
                                {key: "remove_col", name: 'delete col'},
                            ]
                        }
                    },
                    "hsep1": "---------",
                    "make_read_only": true,
                    "borders": true,
                    "mergeCells": true,
        }
   }`

I have created a structure for the options https://jsfiddle.net/AMBudnik/pmfet5va/ but there are some issues for the submenus that you may encounter
https://github.com/handsontable/handsontable/issues?utf8=✓&q=is%3Aissue+is%3Aopen+submenu

I have modified and succeeded, thanks

Great. Thank you for the update. I think that we can close the topic.