Page 1 of 1
Tree questions
Posted: 24 Jun 2019, 21:32
by olegkon
Hi,
How to put a scrollbar in a tree (so when it is expanded and goes below page end, it show a scorllbar) ?
Also is there a way to select a tree node programmatically,
for example make root node initially selected (and showing its children) ?
Please advise.
TIA,
Oleg.
Re: Tree questions
Posted: 09 Aug 2019, 08:17
by vCillusion
Hi
I kept parentId in the children node and travel back from the desired selection to way up by using getNodeWithKey(node, nodelist) method and kept on expanding. I am not sure about how to get the scroll bar to move to the selection.
Regards
Re: Tree questions
Posted: 09 Aug 2019, 19:25
by mikeshugar
I put the tree inside a scroll panel and that worked.
Here is a snippet:
Code: Select all
<p-scrollPanel [style]="{width: '100%'}">
Content
<div class="content-section implementation">
<h3>Single Selection</h3>
<p-tree [value]="filesTree2" selectionMode="single" [(selection)]="selectedFile"
(onNodeSelect)="nodeSelect($event)" (onNodeUnselect)="nodeUnselect($event)"></p-tree>
<div style="margin-top:8px">Selected Node: {{selectedFile ? selectedFile.label : 'none'}}</div>
<h3>Horizontal Tree</h3>
<p-tree [value]="filesTree3" layout="horizontal" selectionMode="single" [(selection)]="selectedFile3" ></p-tree>
<div style="margin-top:8px">Selected Node: {{selectedFile3 ? selectedFile3.label : 'none'}}</div>
........
Re: Tree questions
Posted: 12 Aug 2019, 05:36
by mikeshugar
The Tree demo shows an example of programmatic select, expand, collapse.
It is the tenth one down: Programatic Tree Expansion