TreeNode - Typescript: How to remove a node from a tree?

0

Good evening,

Can anyone give me a hint on how to remove a node from a TreeNode object? I'm using the tree component of PrimeNG . Below is a small part of my code (incomplete). Thank you in advance!

import {TreeModule} from 'primeng/tree';
import {TreeNode} from 'primeng/api';
export class DocumentsComponent implements OnInit {

documentsTree: TreeNode[] = [];


private createNode(category: CategoryModel) {
 let node = {
  data: category,
  label: category.name,
  expandedIcon: "fa-folder-open",
  collapsedIcon: "fa-folder",
  expanded: category.id == 1,
  children: [],
  leaf: false
 };
category.children.forEach(x => node.children.push(this.createNode(x)));
return node;
}

private loadCategoryTree() {

  this.documentsTree = [];
  var node = this.createNode(this.documentCategoryDTO);
  this.documentsTree = [node];
  this.documentsTreeAux = this.documentsTree;
}
    
asked by anonymous 08.02.2018 / 02:55

0 answers