The DropDown Menu component does not have a property to programmatically close.
In my application I put a DropDown Menu as a column of an sfGrid, my problem happens when I drag the grid with the mouse scroll and the DropDown Menu is open it follows the grid visually breaking my application, I thought as a solution to close programmatically using the event @onwhell on the div but the component doesn't offer a property to be programmatically closed, how can I do that?
My code:
Hi Leonardo,
Using the Toggle method of Dropdown Menu component, we can close the popup of dropdown menu component.
Get back to us, if you need any further assistance on this.
Regards,
YuvanShankar A
I used the toggle method to try to programmatically close the popup, I added it in a click event on the test button that I created. It turned out like this:
But instead of the click event closing the popup when it was open, what I left attached happened.
Is there another way to close it programmatically?
Leonardo,
We have checked your reported query and the Toggle method is Opens/closes a Dropdown Button popup based on current state of the Dropdown Button. To resolve this issue, kindly refer to the below code snippet.
|
<SfDropDownButton @ref="DropdownBtn" Content="Profile"> <DropDownButtonEvents OnOpen="OnOpen" OnClose="OnClose"> </DropDownButtonEvents> <DropDownMenuItems> <DropDownMenuItem Text="Dashboard" Id="Dashboard"></DropDownMenuItem> <DropDownMenuItem Text="Notifications" Id="Notifications"></DropDownMenuItem> <DropDownMenuItem Text="User Settings" Id="UserSettings"></DropDownMenuItem> <DropDownMenuItem Text="Log Out" Id="LogOut"></DropDownMenuItem> </DropDownMenuItems> </SfDropDownButton>
<SfButton OnClick="onClick">Close</SfButton>
@code { private bool canClose = false; SfDropDownButton DropdownBtn; private void OnOpen(BeforeOpenCloseMenuEventArgs args) { canClose = true; }
private void OnClose(BeforeOpenCloseMenuEventArgs args) { canClose = false; }
private void onClick() { if (canClose) { DropdownBtn.Toggle(); canClose = false; } } } |
Get back to us if you need any further assistance on this.
- 3 Replies
- 2 Participants
-
LS Leonardo Saraiva
- Jul 4, 2023 12:13 PM UTC
- Jul 10, 2023 01:36 PM UTC