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

How to Enable/Disable Toolbar item in Grid

ToolbarItem has no IsEnabled property

This "Add" item is displayed in toolbar, but it is always in disabled state: 

var toolbaritems = new List<Syncfusion.EJ2.Blazor.Navigations.ItemModel>();
toolbaritems.Add(new Syncfusion.EJ2.Blazor.Navigations.ItemModel() { Text = "Add", TooltipText = "Add new claim", PrefixIcon = "e-add" });

<EjsGrid Toolbar="@toolbaritems"
<GridEvents TValue="DbGeneralOfficeClaim" ... OnToolbarClick="ToolbarClick"></GridEvents>

1 Reply

VN Vignesh Natarajan Syncfusion Team September 24, 2019 06:06 AM UTC

Hi Andrey,  

Thanks for contacting Syncfusion support.  

Query: “This "Add" item is displayed in toolbar, but it is always in disabled state 
We are able to reproduce the similar behavior at our end too when preparing a sample using your code example. You have created custom toolbar item named “Add” which is similar to our inbuilt Toolbar item (used to perform insert operation in Grid). This (inbuilt Add) toolbar item will be enabled only when AllowAdding property of GridEditSettings is enabled, otherwise it will be in disabled.  

Since you have created the custom toolbar with similar name as inbuilt toolbar, it has been considered as inbuilt one and it is in disabled state. To overcome the reported behavior, we suggest you to define the Id property for toolbar items as below  

     List<ItemModel> Toolbaritems = new List<Syncfusion.EJ2.Blazor.Navigations.ItemModel>(); 
    Toolbaritems.Add(new Syncfusion.EJ2.Blazor.Navigations.ItemModel() { Text = "Add", Id="add" , TooltipText = "Add new claim", PrefixIcon = "e-ad" }); 

Note: if you want to perform default actions for this add button, you can enable AllowAdding property of  GridEditSettings.  

<EjsGrid DataSource="@Orders" @ref="Grid" AllowGrouping="true" AllowPaging="true" Height="200" Toolbar="Toolbaritems"> 
    <GridEvents OnToolbarClick="ToolbarClickHandler" TValue="Order"></GridEvents> 
    <GridEditSettings AllowAdding="true"></GridEditSettings>  
.        .            .            .  
Please get back to us if you have further queries.  

Vignesh Natarajan. 

Live Chat Icon For mobile
Up arrow icon