When I use the Menubar component, I need to dynamically display some menu items according to the user authority.
The Menubar component supports visible property, but it does not seem to support variable in addition to hard-coded true or false, because both MenuModel and variable are declared in the data(){} block, MenuModel cannot identify variable.
I can dynamically pass different MenuModels according different user authorities, but is there any flexable way to dynamically display only some menu items?
How to dynamically display menu items in Menubar
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
I see, it makes sense to support functions so we can call it to resolve the value instead of true and false, I'll check this one and get back to you;
https://github.com/primefaces/primevue/issues/286
https://github.com/primefaces/primevue/issues/286
-
- Prime
- Posts: 18616
- Joined: 05 Jan 2009, 00:21
- Location: Cybertron
- Contact:
Try 1.3.1 please;
From the new docs at;
https://primefaces.org/primevue/showcase/#/menumodel
Visibility
It is a common case to hide certain items based on conditions such as user roles, visible property is available to implement such cases by supporting functions that returns booleans or simple booleans.
From the new docs at;
https://primefaces.org/primevue/showcase/#/menumodel
Visibility
It is a common case to hide certain items based on conditions such as user roles, visible property is available to implement such cases by supporting functions that returns booleans or simple booleans.
Code: Select all
const items = [
{
label: 'Remove',
visible: false
},
{
label: 'Delete',
visible: () => this.isUserAdmin()
}
];
-
- Posts: 1
- Joined: 06 Aug 2021, 10:40
visibility option is only working in primevue ,
and it is not working in primereact
and it is not working in primereact
-
- Information
-
Who is online
Users browsing this forum: No registered users and 4 guests