Base solution for your next web application
Open Closed

GetMenuAsync should be sorted by "Order" field #3025


User avatar
0
goldstar25 created

As shown,the method "_userNavigationManager.GetMenuAsync" not sorted by Order,I think this method the default should be sorted by the "order" field.


2 Answer(s)
  • User Avatar
    0
    alirizaadiyahsi created

    Hi,

    You are right. But now, if you are using aspnet zero with angular, then menu items defined as hard-coded in a typescript file.

    For other templates (without angular), "order" propery is added, since it can be expanded, and also they are defined as hard-coded in a class, too.

    Actualy "order" property is reasonable, if you store menu item in DB.

  • User Avatar
    0
    goldstar25 created

    I has order it in " _UserMenuItem.cshtml" and "Default.cshtml":

    <ul class="sub-menu">
                @{var items = Model.MenuItem.Items.OrderBy(p => p.Order).ToList();}
                @for (var i = 0; i < items.Count; i++)
                {
                    var childMenuItem = items[i];
                    @Html.Partial("Components/AdminSideBar/_UserMenuItem", new UserMenuItemViewModel
                    {
                        MenuItem = childMenuItem,
                        MenuItemIndex = i,
                        CurrentPageName = Model.CurrentPageName,
                        RootLevel = false
                    })
                }
            </ul>