How to open complete tree with children by default on landing?

353 Views Asked by At

I have implemented ngx-bootstrap-treeview

Currently with [isOpened]="true" is opening First Level tree only but I have secondly level tree as well which is not opening until I click on it. I tried to find out solution in documentation + PRs but i did not find anything.

<ngx-bootstrap-treeview [isOpened]="true" 
[openedFolderIcon]="faTemplate" 
[closedFolderIcon]="faTemplate"
[isAnimationDisabled]="true"
[selectedLeafIcon]="faTemplate"
[unselectedLeafIcon]="faTemplate"
[tree]="certPathTree" ></ngx-bootstrap-treeview>

I have tree like below :

>Root
   >> Level 1.1
   >> Level 1.2
         >>> Level 2.1
         >>> Level 2.2
         >>> Level 2.3

But It is Showing like below:

>Root
   >> Level 1.1
   >> Level 1.2

If I want to see

>>> Level 2.1
>>> Level 2.2
>>> Level 2.3

Then I have to click on > Level 1.2

Can anyone please help me on same? Please do let me know if anyone need further information. enter link description here Library link : https://github.com/Zokelion/ngx-bootstrap-treeview

1

There are 1 best solutions below

0
On

You can get a reference to your NgxBootstrapTreeviewComponent and call unfoldAll():

@ViewChild('tree') tree: NgxBootstrapTreeviewComponent;
ngAfterViewInit() {
   this.tree.unfoldAll();
}