Page 1 of 1

Expand sub menu by default

Posted: 21 Feb 2019, 15:29
by entho
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.

Re: Expand sub menu by default

Posted: 25 Feb 2019, 12:58
by merve7
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' :

Re: Expand sub menu by default

Posted: 26 Feb 2019, 17:33
by entho
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.

Re: Expand sub menu by default

Posted: 04 Mar 2019, 13:21
by merve7
Hi,
You can assign a variable or you can change expanded attribute in itemClick function in app submenu component.