Add branch lines to tree PrimeNg

Viewed 103

I'm trying to add branch lines to connect children with parent, in a Tree of PrimeNG, but I don't find a solution for that. Any suggestions for that?. I attach a picture about I need, and code below. Thanks

enter image description here

HTML:

<p-tree [value]="files3"filterPlaceholder="Search" [virtualScroll]="true" [filter]="true" filterMode="strict" selectionMode="single" scrollHeight="200px">

TS:

files3: TreeNode[];
files2: TreeNode[];

constructor(private nodeService: NodeService) { }

ngOnInit() {
  this.files2 =  Array.from({length: 5}).map((_,i) => this.createNode(i, 2));
  this.files3 = [
    {
      key: '1',
      label: 'Introduction 1'
  },
    {
        key: '0',
        label: 'Introduction 2',
        children: this.files2
    }
];
console.log(this.files3);
}

createNode(i: number, children: number): TreeNode {
  let node: TreeNode = {
      label: 'Node ' + i,
      data: 'Node ' + i
  };

  return node;
}

}

0 Answers
Related