<<ABP Documents >> Navigation

Source: Internet
Author: User

Document Directory

The content of this section:

    • Create a Menu
      • Registered navigation Provider
    • Show Menu

Each web app has some menus to navigate between pages/screens, and the ABP provides a common framework for creating and displaying menus to users.

Create a Menu

An application may consist of different modules, each module can have its own menu item, in order to define the menu item, we need to create a class that inherits from Navigationprovider.

Suppose you have a main menu that looks like this:

    • Tasks
    • Reports
    • Administration
      • User Management
      • Role Management

Here, the Administration menu has two sub-menu items, and the navigation provider class that creates such a menu should look like this:

 Public classsimpletasksystemnavigationprovider:navigationprovider{ Public Override voidsetnavigation (Inavigationprovidercontext context) {context. Manager.mainmenu. AddItem (NewMenuitemdefinition ("Tasks",                    NewLocalizablestring ("Tasks","Simpletasksystem"), URL:"/tasks", Icon:"FA Fa-tasks"                    )            ). AddItem (NewMenuitemdefinition ("Reports",                    NewLocalizablestring ("Reports","Simpletasksystem"), URL:"/reports", Icon:"FA Fa-bar-chart"                    )            ). AddItem (NewMenuitemdefinition ("Administration",                    NewLocalizablestring ("Administration","Simpletasksystem"), Icon:"FA Fa-cogs"                    ). AddItem (NewMenuitemdefinition ("usermanagement",                            NewLocalizablestring ("usermanagement","Simpletasksystem"), URL:"/administration/users", Icon:"FA fa-users", Requiredpermissionname:"SimpleTaskSystem.Permissions.UserManagement"                            )                    ). AddItem (NewMenuitemdefinition ("rolemanagement",                            NewLocalizablestring ("rolemanagement","Simpletasksystem"), URL:"/administration/roles", Icon:"FA Fa-star", Requiredpermissionname:"SimpleTaskSystem.Permissions.RoleManagement"                            )                    )            ); }}

A menuitemdefinition primarily has a unique name, a localized display name, a URL, and an icon.

    • A menu item that may require a license to display itself to a particular user (viewing the authorization document), Requiredpermissionname attribute is used in this case.
    • A menu item that may depend on a function, the featuredependency attribute is used in this case.
    • A menu item that can define a customdata (user data) and order (ordinal position).

Inavigationprovidercontext has a way to get menu items, add menus, and menu items, so different modules can add their own items to the menu.

One application may have one or more menus, context. Manager.mainmenu points to the default main menu, and we can create and add more menus with the Context.Manager.Menus property.

Registered navigation Provider

After creating the navigation supply, you should register it in the Preinitialize event of our module:

Show Menu

We can inject iusernavigationmanager and use it to get the menu item and display it to the user, so we can create a menu on the server.

The ABP automatically generates a JavaScript API, which is used in the client to get menus and items, The methods and objects in the Abp.nav namespace are used to support these operations, for example: You can get the main menu of an app with Abp.nav.menus.MainMenu, so we can also create a menu on the client.

The ABP template uses this system to create and display menus for users. You can create a project with a template and view the source code for more information.

kid1412 attached: English Original: Http://www.aspnetboilerplate.com/Pages/Documents/Navigation

<<ABP Documents >> Navigation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.