Disable menu item in table depending the model.
Kris-I opened this issue ยท 2 comments
Kris-I commented
Hello,
With MudBlazor, I have this :
<MudTable Items="Model.Datas" Hover="true" Elevation="0">
<HeaderContent>
<MudTh>Field 1</MudTh>
<MudTh>Field 2</MudTh>
</HeaderContent>
<RowTemplate>
<MudTd DataLabel="Name">
<ContextMenuTrigger MenuId="myMenu" Data="@context.Id">
@context.Name
</ContextMenuTrigger>
</MudTd>
</RowTemplate>
</MudTable>
<ContextMenu Id="myMenu">
<Item OnClick="@OnClickType1">Action Type 1</Item>
<Item OnClick="@OnClickType2">Action Type 2</Item>
</ContextMenu>
In the ContextMenuTrigger
, I'd like disable one or several items ('Action Type 1
' or/and 'Action Type 2
') depending of @context.Item1Allowed
Is there a way to disable an or several items in the menu depending Is there a way to do it ?
Thanks,
stavroskasidis commented
I think you need the OnAppearing
event. Please see the demo here (see how an item can be enabled/disabled or visible/hidden depending on context)
perlun commented
Thanks @stavroskasidis! This worked great for me too. ๐ ๐