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. Image for the cookie policy date

Conditional show/hide toolbar items

I am trying to show/hide toolbar items based on value like this :

  <EjsToolbar>
        <ToolbarItems>
            @if (myMode == MyEditMode.None)
            {
                <ToolbarItem OnClick="AddClick" Text="Add New" PrefixIcon="em-icons e-copy" TooltipText="Paste"></ToolbarItem>
                @if (CurrentEntity != null)
                {
                    <ToolbarItem OnClick="EditClick" Text="Edit" PrefixIcon="em-icons e-edit"></ToolbarItem>
                    <ToolbarItem Type="@ItemType.Separator"></ToolbarItem>
                    <ToolbarItem OnClick="EditClick" Text="Delete" PrefixIcon="em-icons e-edit"></ToolbarItem>
                }
            }
            </ToolbarItems>
        </EjsToolbar>

but unfortunatly it is not working .
Do you have suggestions acheiving this ?

2 Replies

AK Alagumeena Kalaiselvan Syncfusion Team January 20, 2020 12:47 PM UTC

Hi Waleed, 

Greetings from Syncfusion Support! 

Currently, the requirement “show/hide the toolbar item based on conditional” is not feasible with toolbar. We will consider your requirement as improvement in our end and provide API to show or hide the tab items.   

You can keep track and update your comments in the following feedback link.  

We have planned to include this improvement feature in 2020 Volume 1 main release, which is planned to roll-out on end of March 2020. We would appreciate your patience until then.  

Regards 
Alagumeena.K


AK Alagumeena Kalaiselvan Syncfusion Team February 6, 2020 10:04 AM UTC

Hi Waleed, 

We are glad to inform that your feature request “Provide API to show/hide Toolbar item” has been implemented and included in our latest release version V17.4.47. Refer below release notes for that 

Also, we have prepared a sample based on your requirement and refer the below code 

@using Syncfusion.EJ2.Blazor.Navigations 
 
<button @onclick="OnClick">Show/Hide</button> 
<EjsToolbar> 
    <ToolbarItems> 
        <ToolbarItem Text="Cut" Visible="@IsVisible"></ToolbarItem> 
        <ToolbarItem Text="Copy"></ToolbarItem> 
        <ToolbarItem Text="Paste"></ToolbarItem> 
        <ToolbarItem Text="Test"></ToolbarItem> 
    </ToolbarItems> 
</EjsToolbar> 
 
@code{ 
    public bool IsVisible = true; 
    public void OnClick() 
    { 
       IsVisible = !IsVisible; 
    } 
} 

  • In above sample, the show/hide customization of toolbar items handled by “Visible” property and you can show/hide the tab item by clicking the “Show/Hide” button .

Kindly get back to us, If you need further assistance. 

Regards 
Alagumeena.K 


Loader.
Live Chat Icon For mobile
Up arrow icon