Hi Robert Tabacaru,Please let us know the following details,1) Could you please confirm us which CSS version and script version you are using in your project?2) Could you please ensure us any customization performs in your end?3) If possible, could you please share the code snippet or video demonstration you are facing a problem.Could you please confirm the above details? So, that we can analyze based on that and provide you a better solution. The information provided would be great help for us to proceed further.Regards,Arunkumar D
Hi Robert Tabacaru,Good day to you.You can achieve this requirement by adding your own custom css class (lets say ‘selected’ css class) to li element in ‘select’ event of Menu. Please refer the below sample link.Regards,Madhan V
Hi Robert Tabacaru,Good day to you.You can achieve this requirement by adding your own custom css class (lets say ‘selected’ css class) to li element in ‘select’ event of Menu. Please refer the below sample link.Regards,Madhan V
Hi Madhan Venkateshan,I tried a little bit alone to achieve another behaviour for this menu and couldn't manage it 100%. There are still some problems.- when I click on the parent item, it shouldn't be selected. The selected item should remain the previous.- once I select a child item, the child's parent should be selected too.- the caret doesn't work anymore as it should, somehow doesn't know when the kebab-menu is closed or open. (I think it's because of open/close on click)here you have what I've changed in my method, to not select the parent item:select(args){let canRemoveClass = false;if (args.element.parentElement.closest('.e-menu-item')){if (this.lastOpenedParentItem != null && this.lastOpenedParentItem.element != null) {removeClass(args.element.parentElement.closest('.e-menu-item').querySelectorAll('.selected'), 'selected');removeClass(document.querySelectorAll('.selected'), 'selected');this.lastOpenedParentItem.element.classList.add('selected');canRemoveClass = true;}}if (args.item.items.length > 0) {this.menuCollapsed = false;this.lastOpenedParentItem = args;} else {if (!canRemoveClass) {removeClass(document.querySelectorAll('.selected'), 'selected');}args.element.classList.add('selected');this.lastOpenedParentItem = args.item.text;this.menuCollapsed = true;this.selectedItem = args.item.text;}}and also inside of html I added a template. I need it to can use routerLink and to translate the text inside of items.Now the parent is selected just the first time when a child is selected. But if you select another Child inside of the parent, the parent loses his selected background.Wouldn't be a possibility to have these features in the menu component without writing this code? It should be very well commented to have an Idea in two Monts about what's happening there. It's hard to maintain it. If I want to change something on it, it's a very high risk to break something else and to have no idea why.Thank you again.
.e-menu-wrapper.e-hamburger ul.e-menu .e-menu-item.e-selected .e-caret {
transform: rotate(-180deg);
} |
Hi Robert Tabacaru,Good day to you.We will consider the issues of ‘caret doesn't change the position’ and ‘want the other parent states, to remain unchanged’ as defect and the fix for the issue will be included in Volume 2 2020 release which will be available in the end of the June month and appreciate your patience until then.Regards,Madhan V
<SfSidebar Width="220px" DockSize="72px" EnableDock="true" Position="@Position" Target="#wrapper" @ref="@sidebar" @bind-IsOpen="@sidebarOpen" HtmlAttributes="@htmlAttribute" MediaQuery="(min-width: 600px)" EnableGestures="true">
<ChildContent>
<SfMenu TValue="MenuItem" Orientation="@VerOrientation">
<MenuEvents TValue="MenuItem" ItemSelected="@OnMenuSelect" OnOpen="@OnOpen"></MenuEvents>
<MenuItems>
@foreach (var item in MainMenuItems)
{
<MenuItem Text="@item.Text" IconCss="@item.IconCss" Url="@item.Url" class=@(item.Text == _selectedItem ? "e-custom-selected" : "")></MenuItem>
}
</MenuItems>
</SfMenu>
</ChildContent>
</SfSidebar>
@code
{
private string _selectedItem = "Dashboard";
private void OnMenuSelect(MenuEventArgs<MenuItem> args)
{
_selectedItem = args.Item.Text;
if (args.Item.Text == "Administrator")
{
//sidebarOpen = true;
userHidden = false;
}
}
}
<style>
.e-menu-container ul .e-menu-item.e-custom-selected .e-menu-url .e-anchor-wrap {
color: #fff;
}
</style>
|