Search results

Open and close ContextMenu

Open and close the ContextMenu manually whenever required by using the open and close methods. In the following sample, to open the ContextMenu at specified position the Open method is used with X and Y coordinates and to close ContextMenu Close method can be used.

@using Syncfusion.EJ2.Blazor.Navigations
@using Syncfusion.EJ2.Blazor.Buttons

<div id="target">
    <EjsContextMenu Target="#target" Items="@MenuItems" @ref="ContextMenuObj"></EjsContextMenu>
    <EjsButton CssClass="e-btn" Onclick="open">Open ContextMenu</EjsButton>

@code {
    EjsContextMenu ContextMenuObj;
    public List<MenuItem> MenuItems = new List<MenuItem>{
        new MenuItem { Text = "Cut" },
        new MenuItem { Text = "Copy" },
        new MenuItem { Text = "Paste" }
    private void open()
        ContextMenuObj.Open(40, 20);

Output be like

ContextMenu Sample