|
@using Syncfusion.EJ2.Blazor.Navigations
@using Syncfusion.EJ2.Blazor.Buttons
<div class="control-section">
<div class="contextmenu-control">
<div id="contextmenutarget">Right click/Touch hold to open the ContextMenu</div>
<EjsContextMenu @ref="cmObj" Target="@target" Items="@MenuItems"></EjsContextMenu>
</div>
</div>
<div id="contextmenutarget1">ContextMenu</div>
<EjsButton CssClass="e-flat" Content="onTargetChange" @onclick="onTargetChange"></EjsButton>
<EjsButton CssClass="e-flat" Content="onClose" @onclick="onClose"></EjsButton>
@code{
public string target = "#contextmenutarget";
EjsContextMenu cmObj;
public List<MenuItem> MenuItems = new List<MenuItem>
{
new MenuItem { Text="Cut" },
new MenuItem { Text="Copy" },
new MenuItem { Text ="Paste"},
new MenuItem { Separator= true},
new MenuItem { Text = "Link"},
new MenuItem { Text = "New Comment"}
};
public void onTargetChange()
{
target = "#contextmenutarget1"; // to change the target in the button click
}
public void onClose()
{
cmObj.Close(); // to hide the context menu
}
} |