sfMenu equivelant to NavigationManager.NavigateTo forcereload=true

I'm trying to reload the current URL/Page through the an SfMenu item but the page does not reload as the current and new URL are the same. WithNavigationManager.NavigateTo you can set the forcereload flag to true to resolve this situation. Is there anequivalent for SfMenu?

1 Reply 1 reply marked as answer

GK Gayathri KarunaiAnandam Syncfusion Team June 4, 2021 02:43 AM UTC

Hi Michael, 

We have checked your reported query. We can achieve your requirement by using NavigationManager.NavigateTo with force reload parameter as true on ItemSelected event of MenuBar. Please check the below code snippet. 

@using Syncfusion.Blazor.Navigations  
@inject NavigationManager NavigationManager  
  
<SfMenu TValue="MenuItem">  
    <MenuItems>  
        <MenuItem Text="Appliances">  
            <MenuItems>  
                <MenuItem Text="Washing Machine"></MenuItem>  
                <MenuItem Text="Air Conditioners"></MenuItem>  
            </MenuItems>  
        </MenuItem>  
        <MenuItem Text="Entertainment">  
            <MenuItems>  
                <MenuItem Text="Home Theatres"></MenuItem>  
                <MenuItem Text="Gaming Laptops"></MenuItem>  
            </MenuItems>  
        </MenuItem>  
        <MenuItem Text="Home"></MenuItem>  
    </MenuItems>  
    <MenuEvents TValue="MenuItem" ItemSelected="Selected"></MenuEvents>  
</SfMenu>  
@code{  
    public string ItemSelected;  
    public void Selected(MenuEventArgs<MenuItem> args)  
    {  
        string Url = "";  
        if (args.Item.Text == "Washing Machine")  
            Url = "/washingmachine/";  
        if (args.Item.Text == "Home")  
            Url = "/";  
        if (args.Item.Text == "Air Conditioners")  
            Url = "/airconditioner/";  
        
        NavigationManager.NavigateTo(Url, true);  
    }  
} 
  



Please get back to us, if you need further assistance. 

Regards, 
Gayathri K 


Marked as answer
Loader.
Up arrow icon