I would like to create menu from the items stored in the database, instead of hardwiring them in AppNavigationProvider.cs. Do you have a sample example for this purpose? What should be the database look like for this purpose and in what format menus should be returned to abp.nav.menus.MainMenu?
I am using ANZ v8 MVC Core and Jquery.
11 Answer(s)
-
0
This is inconsistent with the design of the framework, You may need to change a lot of framework built-in components.The menu may depend on permissions or features.
If you only want to create some dynamic menus, you can add it to the current function, read these menus from the database, and display them in the UI, so that it will not change the design of the framework.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Do you mean I should get menu from database in
SetNavigationfunction ofAppNavigationProvider1as shown below?public override void SetNavigation(INavigationProviderContext context) { var menu = context.Manager.Menus[MenuName] = new MenuDefinition(MenuName, new FixedLocalizableString("Main Menu")); var myList = _myMenuService.GetMenusByMyParameter(_mySession.myParameter); foreach(MyMenuItem myMenuItem in myList) { menu.AddItem(new MenuItemDefinition( myMenuItem.Text, L(myMenuItem.Text), url: myMenuItem.url, icon: myMenuItem.icons, permissionDependency: new SimplePermissionDependency(myMenuItem.permissionString) ) } }Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
XXXNavigationProviderwill only read the menu when the application starts, if this is what you need you can read the database in theSetNavigationmethod.Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Do we have access to AbpSession.UserId in SetNavigation method?
Yes, I just need to get the menu from the database and display them with any permission dependcies as well. Is this a suitable placce?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
NavigationProviderwill be initialized when the application starts. Although you can injectIAbpSession, it may have no value.Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
So what would be the best place to read menu from the database? I would need a value from session to retreive menu from the database. You mentioned current function in previous reply where is this function? Please reply comprehensively if possible with example so that I can close this ticket quickly. Thanks
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
You can combine Abp's menu(
_userNavigationManager.GetMenuAsync) with your dynamic menu inView.It's easiest to get extra menus this way.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Are you referring to following code in
AppMenuViewComponentvar model = new MenuViewModel { Menu = await _userNavigationManager.GetMenuAsync(AppNavigationProvider.MenuName, _abpSession.ToUserIdentifier()), CurrentPageName = currentPageName };How will the menu order be handled? Can I recreate Abp's menu in my database and then just get all menu from the database instead of getting Abp's from navigationManager and then appending mine from the database?
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Yes, and
HeaderViewComponent.You cannot change the design of ABP. Of course you can design your own menu system. Read the menu from the database.
How will the menu order be handled?
https://github.com/aspnetzero/aspnet-zero-core/issues/3013
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
I am unable to access following link, I am logged in with my credentials to aspnetzero support. https://github.com/aspnetzero/aspnet-zero-core/issues/3013
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image) -
0
Hi,
You need to add your GitHub user on https://aspnetzero.com/LicenseManagement.
Markdown is supportedCopy & paste or drag & drop images (max 30 MB per image)