Skip to content

Commit

Permalink
Updated tree component
Browse files Browse the repository at this point in the history
  • Loading branch information
slh17006 committed Feb 10, 2020
1 parent 0e42842 commit 026f106
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/app/tree/tree.component.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

<p-tree #expandingTree [value]="filesTree10"></p-tree>
<p-tree #expandingTree [value]="filesTree"></p-tree>
<div style="margin-top: 8px">
<button pButton type="button" label="Expand all" (click)="expandAll()" style="margin-right: .25em"></button>
<button pButton type="button" label="Collapse all" (click)="collapseAll()"></button>
Expand Down
31 changes: 4 additions & 27 deletions src/app/tree/tree.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,45 +11,22 @@ import {NodeService} from '../node.service';
export class TreeComponent implements OnInit {
@ViewChild('expandingTree', {static: false})
expandingTree: Tree;
filesTree10: TreeNode[];
filesTree: TreeNode[];

constructor(private nodeService: NodeService, private messageService: MessageService) { }

ngOnInit() {
this.nodeService.getFiles().then(files => this.filesTree10 = files);
this.nodeService.getFiles().then(files => this.filesTree = files);
}

// nodeSelect(event) {
// this.messageService.add({severity: 'info', summary: 'Node Selected', detail: event.node.label});
// }
//
// nodeUnselect(event) {
// this.messageService.add({severity: 'info', summary: 'Node Unselected', detail: event.node.label});
// }
//
// nodeExpandMessage(event) {
// this.messageService.add({severity: 'info', summary: 'Node Expanded', detail: event.node.label});
// }
//
// nodeExpand(event) {
// if(event.node) {
// // in a real application, make a call to a remote url to load children of the current node and add the new nodes as children
// this.nodeService.getLazyFiles().then(nodes => event.node.children = nodes);
// }
// }
//
// viewFile(file: TreeNode) {
// this.messageService.add({severity: 'info', summary: 'Node Selected with Right Click', detail: file.label});
// }

expandAll(){
this.filesTree10.forEach( node => {
this.filesTree.forEach( node => {
this.expandRecursive(node, true);
} );
}

collapseAll(){
this.filesTree10.forEach( node => {
this.filesTree.forEach( node => {
this.expandRecursive(node, false);
} );
}
Expand Down

0 comments on commit 026f106

Please sign in to comment.