Reputation: 435
I'm using PrimeNG treetable component and I want to get all the children of a node when I click on getChildrens
button near that node.
Also, I want to get all the parents of that node when I click the getParents
button near the same node.
The goal is to give a different style to the children and parents of the node once I select the appropriate button.
Is PrimeNG treetable offer that functionnality to get all the children and parents of a node ?
Upvotes: 2
Views: 1506
Reputation: 1
getParent(node, arr) {
if (node && node.label) {
let result;
arr.unshift({
key: node.tag,
value: node.label,
data: node.data
})
if (node.parent) {
result = this.getchildren(node.parent, arr)
} else {
result = arr
}
return result
} else {
this.initdata.ancestorValue = []
arr = []
}
}
getchildren(node, arr) {
if (node && node.label) {
let result;
arr.unshift({
key: node.tag,
value: node.label,
data: node.data
})
if (node.parent) {
result = this.getParent(node.parent, arr)
} else {
result = arr
}
return result
}
return arr
}
console.log(this.getParent(event.node,[])
Upvotes: 0