Hi J
Good day to you.
We have analyzed your requirement “With DropDownButton can one item or the parent item be disabled?” in Blazor DropDownButton and you can achieve your requirement by using Disabled property to disable the dropdown button and using OnItemRender event to disable the dropdown item, as per in below code snippet.
Index.razor
<EjsDropDownButton Disabled="true" Content="Disabled Button"> <DropDownButtonItems> <DropDownButtonItem Text="Dashboard"></DropDownButtonItem> <DropDownButtonItem Text="Notifications"></DropDownButtonItem> <DropDownButtonItem Text="User Settings"></DropDownButtonItem> <DropDownButtonItem Text="Log Out"></DropDownButtonItem> </DropDownButtonItems> </EjsDropDownButton>
<EjsDropDownButton Content="Profile"> <DropDownButtonEvents OnItemRender="@itemRender"></DropDownButtonEvents> <DropDownButtonItems> <DropDownButtonItem Text="Dashboard"></DropDownButtonItem> <DropDownButtonItem Text="Notifications"></DropDownButtonItem> <DropDownButtonItem Text="User Settings"></DropDownButtonItem> <DropDownButtonItem Text="Log Out"></DropDownButtonItem> </DropDownButtonItems> </EjsDropDownButton>
@code { private void itemRender(MenuEventArgs args) { if (args.Item.Text == "Notifications") { args.Element.AddClass(new string[] { "e-disabled" }); } } } |
Sample link:
Could you please check the above sample and get back to us with more information if we misunderstood your requirement or need further assistance.
Regards,
Sridhar A.