Open girishus opened 8 months ago
How I get selected value (DropdownItem) from Modal class - Dropdown in side dropdown menu
e.g.
<Modal @ref="modal" Title="Modal title">
<FooterTemplate>
<Button Color="ButtonColor.Secondary" @onclick="OnHideModalClick">Close</Button>
<Button Color="ButtonColor.Primary" >Save changes</Button>
</FooterTemplate>
<Button Color="ButtonColor.Primary" @onclick="OnShowModalClick">Show Modal
How I get selected value (DropdownItem) from Modal class - Dropdown in side dropdown menu e.g. <Modal @ref="modal" Title="Modal title"> Dropdown button <DropdownMenu @OnHidden="OnDropdownHiddenAsync"> @foreach (var dept in DepartmentDatas) { @dept.DisplayText } <Button Color="ButtonColor.Secondary" @OnClick="OnHideModalClick">Close Save changes <Button Color="ButtonColor.Primary" @OnClick="OnShowModalClick">Show Modal
@girishus Please ask this as a seperate question in the discussion. I think you have to implement a custom logic.
@girishus you can apply Disabled
state for each item in the dropdown. This way the drop down opens but you cannot click on the elements which are disabled.
<Dropdown>
<DropdownToggleButton Color="ButtonColor.Secondary">Dropdown button</DropdownToggleButton>
<DropdownMenu>
<DropdownItem To="#" Type="ButtonType.Link" Disabled="true">Action</DropdownItem>
<DropdownItem To="#" Type="ButtonType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="ButtonType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
I used the Disabled property on the
Here's an example from my code:
<Dropdown Size="Size.Small" Disabled="@(!EnablePoFields)">
</Dropdown>
@tjdennis Try this.
<Dropdown>
<DropdownToggleButton Color="ButtonColor.Secondary">Dropstart</DropdownToggleButton>
<DropdownMenu>
<DropdownItem To="#" Type="ButtonType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="ButtonType.Link" Disabled="true">Another action</DropdownItem>
<DropdownItem To="#" Type="ButtonType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
Hi @gvreddy04
The original question above asked how to disable the entire DropDown control, not just an individual item in the DropDown list. Putting the Disabled property on the DropDown tag will do that.
His only error was trying to put it on the DropdownToggleButton tag instead of the DropDown tag.
Regards,
When using Dropdown with Split="true"
and binding Disabled
to a variable on the page (Disabled="@actionInProgress"
), only the DropdownActionButton
gets disabled, but the DropdownToggleButton
stays active.
Trying to manually disable the ToggleButton as well with disabled="@actionInProgress"
works for disabling, but after re-enabling the ToggleButton, the menu doesn't open anymore.
How can we fix this?
Hi @gvreddy04
The original question above asked how to disable the entire DropDown control, not just an individual item in the DropDown list. Putting the Disabled property on the DropDown tag will do that.
His only error was trying to put it on the DropdownToggleButton tag instead of the DropDown tag.
Regards,
Demo Link: https://demos.blazorbootstrap.com/dropdown#disabled
<Dropdown Color="DropdownColor.Secondary" Disabled="@isDropdownDisabled">
<DropdownToggleButton>Dropstart</DropdownToggleButton>
<DropdownMenu>
<DropdownItem To="#" Type="DropdownItemType.Link">Action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Another action</DropdownItem>
<DropdownItem To="#" Type="DropdownItemType.Link">Something else here</DropdownItem>
</DropdownMenu>
</Dropdown>
<div class="mt-3">
<Button Color="ButtonColor.Primary" Size="ButtonSize.Small" @onclick="EnableDropdown">Enable</Button>
<Button Color="ButtonColor.Danger" Size="ButtonSize.Small" @onclick="DisableDropdown">Disable</Button>
</div>
@code
{
private bool isDropdownDisabled = true;
private void EnableDropdown() => isDropdownDisabled = false;
private void DisableDropdown() => isDropdownDisabled = true;
}
Discussed in https://github.com/vikramlearning/blazorbootstrap/discussions/371