Every web application has some menu to navigate between pages/screens. ASP.NET Boilerplate provides a common ifrastructure to create and show menu to users.

每个Web应用程序都有一些菜单在页面/屏幕之间导航。ASP.NET提供了一个通用的ifrastructure样板文件创建和显示菜单的用户。

Creating Menus

An application may be consists of different modules and each module can have it's own menu items. To define menu items, we need to create a class derived from NavigationProvider.

Assume that we have a main menu as shown below:

应用程序可以由不同的模块组成,每个模块都可以有自己的菜单项。定义菜单项,我们需要创建一个类派生navigationprovider。

假设我们有一个主菜单,如下所示:

  • Tasks
  • Reports
  • Administration
    • User management
    • Role management

Here, Administration menu item has two sub menu items. Example navigation provider class to create such a menu can be as below:

public class SimpleTaskSystemNavigationProvider : NavigationProvider
{
public override void SetNavigation(INavigationProviderContext context)
{
context.Manager.MainMenu
.AddItem(
new MenuItemDefinition(
"Tasks",
new LocalizableString("Tasks", "SimpleTaskSystem"),
url: "/Tasks",
icon: "fa fa-tasks"
)
).AddItem(
new MenuItemDefinition(
"Reports",
new LocalizableString("Reports", "SimpleTaskSystem"),
url: "/Reports",
icon: "fa fa-bar-chart"
)
).AddItem(
new MenuItemDefinition(
"Administration",
new LocalizableString("Administration", "SimpleTaskSystem"),
icon: "fa fa-cogs"
).AddItem(
new MenuItemDefinition(
"UserManagement",
new LocalizableString("UserManagement", "SimpleTaskSystem"),
url: "/Administration/Users",
icon: "fa fa-users",
requiredPermissionName: "SimpleTaskSystem.Permissions.UserManagement"
)
).AddItem(
new MenuItemDefinition(
"RoleManagement",
new LocalizableString("RoleManagement", "SimpleTaskSystem"),
url: "/Administration/Roles",
icon: "fa fa-star",
requiredPermissionName: "SimpleTaskSystem.Permissions.RoleManagement"
)
)
);
}
}

A MenuItemDefinition can basically have a unique name, a localizable display name, a url and an icon. Also,

一个menuitemdefinition基本上能有一个独特的名字,一个本地化的显示名称,URL和图标

  • A menu item may require a permission to show this menu to a particular user (See authorization document). requiredPermissionName property can be used in this case.
  • A menu item can be depend on a feature. featureDependency property can be used in this case.
  • A menu item can define a customData and order.
  • 菜单项可能需要允许将菜单显示给特定用户(请参阅授权文档)。requiredpermissionname属性可以在这种情况下使用。
    菜单项可以依赖于一个特性。FeatureDependency属性可以在这种情况下使用。
    菜单项可以定义一个customdata和order。

INavigationProviderContext has methods to get existing menu items, add menus and menu items. Thus, different modules can add it's own items to the menu.

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.

inavigationprovidercontext有方法让现有的菜单项,添加菜单和菜单项。因此,不同的模块可以将自己的项目添加到菜单中。

应用程序中可能有一个或多个菜单。context.manager.mainmenu引用默认的主菜单。我们可以创建和使用context.manager.menus属性添加更多的菜单。

Registering Navigation Provider

After creating the navigation provider, we should register it to ASP.NET Boilerplate configuration on PreInitialize event of our module:

Configuration.Navigation.Providers.Add<SimpleTaskSystemNavigationProvider>(); 

Showing Menu

IUserNavigationManager can be injected and used to get menu items and show to the user. Thus, we can create menu in server side.

ASP.NET Boilerplate automatically generates a javascript API to get menu and items in client side. Methods and objects under abp.nav namespace can be used for this purpose. For instance, abp.nav.menus.MainMenucan be used to get main menu of the application. Thus, we can create menu in client side.

ASP.NET Boilerplate templates uses this system to create and show menu to the user. Try to create a template and see source codes for more.

iusernavigationmanager可以注入,用得到的菜单项和显示给用户。因此,我们可以在服务器端创建菜单。

ASP.NET样板自动生成JavaScript API来获取客户端菜单项。在abp.nav命名空间对象和方法可用于这一目的。例如,abp.nav.menus.mainmenucan被用于获得应用程序主菜单。因此,我们可以在客户端创建菜单。

ASP.NET的模板模板使用本系统创建和显示菜单的用户。尝试创建一个模板并查看更多的源代码。

ABP框架系列之三十七:(Navigation-导航)的更多相关文章

  1. ABP框架系列之三十四:(Multi-Tenancy-多租户)

    What Is Multi Tenancy? "Software Multitenancy refers to a software architecture in which a sing ...

  2. ABP框架系列之三十九:(NLayer-Architecture-多层架构)

    Introduction Layering of an application's codebase is a widely accepted technique to help reduce com ...

  3. ABP框架系列之十七:(Data-Filters-数据过滤)

    Introduction It's common to use the soft-deletepattern which is used to not delete an entity from da ...

  4. ABP框架系列之三十三:(Module-System-模块系统)

    Introduction ASP.NET Boilerplate provides an infrastructure to build modules and compose them to cre ...

  5. ABP框架系列之三:(Entity Framework Integration-实体框架集成)

    ASP.NET Boilerplate can work with any O/RM framework. It has built-in integration with EntityFramewo ...

  6. ABP框架系列之三十八:(NHibernate-Integration-NHibernate-集成)

    ASP.NET Boilerplate can work with any O/RM framework. It has built-in integration with NHibernate. T ...

  7. ABP框架系列之三十二:(Logging-登录)

    Server Side(服务端) ASP.NET Boilerplate uses Castle Windsor's logging facility. It can work with differ ...

  8. ABP框架系列之三十五:(MVC-Controllers-MVC控制器)

    Introduction ASP.NET Boilerplate is integrated to ASP.NET MVC Controllers via Abp.Web.Mvc nuget pack ...

  9. ABP框架系列之三十六:(MVC-Views-MVC视图)

    Introduction ASP.NET Boilerplate is integrated to MVC Views via Abp.Web.Mvc nuget package. You can c ...

随机推荐

  1. 刘志梅201771010115.《面向对象程序设计(java)》第四周学习总结

    实验四 类与对象的定义及使用 实验时间 2018-9-20 1.实验目的 (1)预定义类:(不是所有类都具有面向对象特征) 构造器的类名和方法名相同,是一种特殊的方法,用来构造并初始化对象. (2)用 ...

  2. springmvc的简单使用以及ssm框架的整合

    Spring web mvc是基于servlet的一个表现层框架 首先创建一个简单的web工程了解它的使用 web.xml的配置 <?xml version="1.0" en ...

  3. Emscripten 安装和使用

    OS: Windows 10 x64 I. install 0. pre install Python2.7 Node js Java 1. down git clone https://github ...

  4. html: 仿制soundmanager2右上角面板

    仿制 http://schillmania.com/projects/soundmanager2/#volume 右上角面板 <style type="text/css"&g ...

  5. 深度学习原理与框架-猫狗图像识别-卷积神经网络(代码) 1.cv2.resize(图片压缩) 2..get_shape()[1:4].num_elements(获得最后三维度之和) 3.saver.save(训练参数的保存) 4.tf.train.import_meta_graph(加载模型结构) 5.saver.restore(训练参数载入)

    1.cv2.resize(image, (image_size, image_size), 0, 0, cv2.INTER_LINEAR) 参数说明:image表示输入图片,image_size表示变 ...

  6. tmp32dll\sha1-586.asm(1432) : error A2070:invalid instruction operands 编译openssl出错

    vs命令行工具编译openssl最新版本的时候报perl版本太低. 后来换了openssl 1.0.2的版本旧版本到是可以正常编译了,但是1.0.2应该是版本还是优点新. 编译的时候报了下面的错误: ...

  7. Redux-persist使用

    redux-persist作用是将store中的数据缓存到浏览器中,减少数据请求,每当白名单中的数据发生变化,才会进行一次更新缓存的操作,并且这个数据缓存是存在localStorage中的,不是会话级 ...

  8. proposal-cancelable-promises

    fetch 从来就没行过,最大的优势就是"新标准",但是 proposal-cancelable-promises 被 withdrawn,就导致了 fetch 发起的请求不可能被 ...

  9. grabcut mask

    #include "opencv2/opencv.hpp" using namespace cv; void main() { Mat src = imread("E:\ ...

  10. JS脚本-零星片段

    1.这种写法:(function(){})(),同时注意:原生的异步对象的兼容性实例化方法 <script> document.domain = "qq.com"; x ...