We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Ability to call an action when when MenItem clicked

Thread ID:

Created:

Updated:

Platform:

Replies:

146681 Aug 13,2019 11:53 PM UTC Jan 13,2020 05:05 AM UTC Blazor 3
loading
Tags: Menu Bar
Dominick Marciano
Asked On August 13, 2019 11:53 PM UTC

I am trying to implement a menu bar, however I need the ability for some of the menu items to open a modal window.  I notice that the MenuItem class has a Text and Url property but it doesn't appear to have any event handlers.  Is it possible to specify an action when certain menu items are clicked vs. just navigating to another page?

Sangeetha Priya Murugan [Syncfusion]
Replied On August 14, 2019 08:26 AM UTC

Hi Dominick, 

Thank you for contacting Syncfusion support. 

We have checked your reported requirement and it can be achievable in Menu by using ItemSelected event as like in the below code example. 

CODE SNIPPETS: 

<EjsMenu Items="@menuItems"> 
    <MenuEvents ItemSelected="onSelect"></MenuEvents> 
</EjsMenu> 
<div id="target"> 
    <EjsDialog @ref="DialogObj" Target="#target" Height="270px" Width="500px" ShowCloseIcon="true" @bind-Visible="@Visibility"> 
        ..// 
    </EjsDialog> 
    </div> 
 
@code{ 
    EjsDialog DialogObj; 
    public bool Visibility { get;set; } = false; 
    private List<MenuItem> menuItems = new List<MenuItem>{ 
            new MenuItem 
            { 
                Text = "File", 
                Items = new List<MenuItem> 
                { 
                    new MenuItem { Text= "Open" },  
                    new MenuItem { Text= "Navigate", Url="counter" },  // Url property, for navigating to counter page. 
                } 
            }, 
             ..// 
    }; 
 
    private void onSelect(MenuEventArgs args) 
    { 
        if (args.Item.Text == "Open"// To check the selected item text 
            DialogObj.Show();  // To open the modal dialog. 
    } 
    } 

For your convenience, we have prepared the sample based on our requirement. Please find the link below. 


Could you please check the above sample and get back to us, if you need any further assistance on this. 

Regards, 
Sangeetha M 


j
Replied On January 12, 2020 09:15 AM UTC

This is nice, I used this.

Saranya Dhayalan [Syncfusion]
Replied On January 13, 2020 05:05 AM UTC

Hi Dominick, 
 
Thanks for the update 
 
Please let us know, if you need any further assistance on this.  
 
Regards, 
Saranya D 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon