How to dynamically display menu items in Menubar

UI Components for Vue
Post Reply
findream
Posts: 6
Joined: 21 Feb 2020, 05:18

20 Apr 2020, 09:45

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?

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

20 Apr 2020, 15:50

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

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

23 Apr 2020, 09:39

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.

Code: Select all

const items = [
    {
        label: 'Remove',
        visible: false
    },
    {
        label: 'Delete',
        visible: () => this.isUserAdmin()
    }
];

subhasbodaki
Posts: 1
Joined: 06 Aug 2021, 10:40

06 Aug 2021, 10:42

visibility option is only working in primevue ,
and it is not working in primereact

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests