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

Menu Bar change item text

Thread ID:

Created:

Updated:

Platform:

Replies:

149973 Dec 16,2019 05:34 PM UTC Dec 19,2019 07:43 PM UTC Blazor 1
loading
Tags: Menu Bar
Fabrizio Alessandro
Asked On December 16, 2019 05:34 PM UTC

Hello,

Is it possible to change the text of a MenuItem of a EjsMenu control?

I tried something like this without success:

<EjsMenu Items="@_menuItems">
    <MenuEvents ItemSelected="MenuItemSelected" />
</EjsMenu>

private List<MenuItem> _menuItems = new List<MenuItem>
    {
        new MenuItem{ Text = "Item 1" },
        new MenuItem{ Text = "Item 2" },
        new MenuItem{ Text = "Item 3" }
    };

In a button click:
_menuItems[1].Text = "Test";
StateHasChanged();


Thank you

Arunkumar Devendiran [Syncfusion]
Replied On December 19, 2019 07:43 PM UTC

Hi Fabrizio Alessandro, 
 
Thanks for your patience. 
 
We have checked your reported query and you can achieve this by using deserialize the serialized menuItems and we have created the sample for your requirement, in that we have change to the menu items text on button click. Please refer the below code snippet and sample link. 
 
Index.razor 
 
@using Newtonsoft.Json; 
 
<EjsMenu Items="@_menuItems"></EjsMenu> 
<EjsButton @onclick="onClick" Content="Click"></EjsButton> 
@code { 
    private List<MenuItem> _menuItems = new List<MenuItem> 
{ 
        new MenuItem{ Text = "Item 1" }, 
        new MenuItem{ Text = "Item 2" }, 
        new MenuItem{ Text = "Item 3" } 
    }; 
    private void onClick() 
    { 
        List<MenuItem> NewMenuItems = JsonConvert.DeserializeObject<List<MenuItem>>(JsonConvert.SerializeObject(_menuItems)); 
        NewMenuItems[1].Text = "Text"; 
        this._menuItems = NewMenuItems; 
    } 
} 
 
 
 
Sample Link: 
 
Could you please check the above link and get back to us with more information if we misunderstood your requirement or need further assistance. 
 
Regards, 
Arunkumar 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