Base solution for your next web application
Open Closed

Configuring Menus #888


User avatar
0
okeziestanley created

"There may be one or more menus in an application. context.Manager.MainMenu references the default, main menu. We can create and add more menus using context.Manager.Menus property."

Found this on the documentation page. Can anyone help me with more info on how to define and use custom menus. The documentation only explains the Main Menu. I can't seem to wrap my head around defining custom menus. Thanks


3 Answer(s)
  • User Avatar
    0
    kayagultekin created

    I wonder that too recently and while playing around what I did to get it working was: to define a new menu using MenuDefinition

    MenuDefinition NewMenu = new MenuDefinition("NewMenu", new LocalizableString("NewMenu", YourProjectNameConsts.LocalizationSourceName));
    

    Populate that newly defined menu with fresh items:

    NewMenu.AddItem(
    new MenuItemDefinition(
            "YourPage",
            new LocalizableString("YourPage", GreenPlainsConsts.LocalizationSourceName),
            url: "#/YourPage",
            icon: "fa fa-home"
        )
    );
    

    And eventually add newmenu the the menus mentioned in the documentation:

    context.Manager.Menus.Add("NewMenu", NewMenu);
    

    There you have it! This code might not be of the best quality so it should be reviewed by a master.

  • User Avatar
    0
    hole7 created

    Hi,

    You can define your custom menu definition:

    var leftMenu = new MenuDefinition("LeftMenu", new FixedLocalizableString("LeftMenu"));

    then add items to leftMenu.

    And add to menu context: context.Manager.Menus.Add("LeftMenu", leftMenu);

    Use in js: vm.menu = abp.nav.menus.LeftMenu;

  • User Avatar
    0
    okeziestanley created

    Thanks a lot guys