Expand sub menu by default

Post Reply
entho
Posts: 2
Joined: 19 Oct 2017, 13:49

21 Feb 2019, 15:29

Hi,
I want to have a specific sub-menu expanded by default on load, but so far it seems I miss something.

Image

Visibility is working fine, but with the expanded property I do not get it to work.

Any idea how to accomplish this are welcome.
Thank you.

merve7
Posts: 623
Joined: 12 Sep 2017, 10:44

25 Feb 2019, 12:58

Hi,
Firstly, please add expanded: true in menu model;

Code: Select all

                    //other codes
                    {label: 'User Profile', icon: 'pi pi-fw pi-user', badge: 2, expanded: true,
                    //other codes
Secondly, add child.expanded near isActive in 484th line;

Code: Select all

            <li [ngClass]="{'layout-root-menuitem':root ,'active-menuitem': isActive(i) || child.expanded }" [class]="child.badgeStyleClass"
Lastly, add child.expanded near isActive in 513th line;

Code: Select all

'visible' : 'hidden' : isActive(i) || child.expanded  ? 'visibleAnimated' :

entho
Posts: 2
Joined: 19 Oct 2017, 13:49

26 Feb 2019, 17:33

Hi merve7,

thanks for the quick answer - that helped me a step further.

But now it is always expanded and cannot be collapsed on mouse-click by the user.
Do I misunderstand the functionality at this point?

Thanks again.

merve7
Posts: 623
Joined: 12 Sep 2017, 10:44

04 Mar 2019, 13:21

Hi,
You can assign a variable or you can change expanded attribute in itemClick function in app submenu component.

Post Reply

Return to “Babylon - PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 0 guests