Can not use method and event of menu context

Hi you,

I using diagram control in version 19.1.69 but can not use method and event of menu context for render and open. Can you help me.



1 Reply

AR Aravind Ravi Syncfusion Team July 19, 2021 11:59 AM UTC

Hi Nguyen, 
 
We cannot able to reproduce the reported issue at our end. On further analysis of the provided code snippet we suspect that you does not call the contextMenuBeforeItemRender event in the tag level. So that event does not gets worked. Please refer to the below code snippet for how to use the context menu event 
 
<ejs-diagram id="diagram" ref="diagram" :width='width' :height='height' :nodes='nodes' :contextMenuBeforeItemRender ="contextMenuBeforeItemRender" :contextMenuSettings='contextMenuSettings'></ejs-diagram> 
 
data () { 
        return { 
            width: "1000px", 
            height: "700px", 
            connectors: connectors, 
            nodes: nodes, 
            contextMenuSettings: { 
          //Enables the context menu 
          show: true, 
          items: [{ 
             text: 'Cut', id: 'Cut', target: '.e-diagramcontent', 
             iconCss: 'e-Cut' 
          }, 
          { 
             text: 'Copy', id: 'Copy', target: '.e-diagramcontent', 
             iconCss: 'e-Copy' 
          }], 
          // Hides the default context menu items 
         showCustomMenuOnly: true, 
            }, 
// Define the context menu event outside context menu settings 
             contextMenuBeforeItemRender: (args) => { 
            // To render template in li. 
            let shortCutSpan = createElement('span'); 
            let text = args.item.text; 
            let shortCutText = text === 'Cut' ? 'Ctrl + S' : (text === 'Copy' ? 
                'Ctrl + U' : 'Ctrl + Shift + I'); 
            shortCutSpan.textContent = shortCutText; 
            args.element.appendChild(shortCutSpan); 
            shortCutSpan.setAttribute('class', 'shortcut'); 
         }, 
        } 
    } 
 
In case if the issue still replicates, please share us a simple sample replicating issue. This would help us to serve you better. 
 
Regards 
Aravind Ravi 


Loader.
Up arrow icon