ngx-treeview
ngx-treeview copied to clipboard
How get parent value
From this treeview we only get child tree value, How I get the parent node value?
@rocky-bgta I can do it from here https://leovo2708.github.io/ngx-treeview/#/advanced
I want when all the children of a Parent are selected, then instead of the id of the parent's children, the output is id parent? Can anyone help?
EXAMPLE
{
text: 'Frontend',
value: 911,
children: [
{ text: 'Angular 1', value: 9111, checked:true },
{ text: 'Angular 2', value: 9112, checked:true },
{ text: 'ReactJS', value: 9113, checked:true },
],
},
OUTPUT => 911
``
I want when all the children of a Parent are selected, then instead of the id of the parent's children, the output is id parent? Can anyone help?
EXAMPLE
{ text: 'Frontend', value: 911, children: [ { text: 'Angular 1', value: 9111, checked:true }, { text: 'Angular 2', value: 9112, checked:true }, { text: 'ReactJS', value: 9113, checked:true }, ], },
OUTPUT => 911
Answer
onSelectedChange(downlineItems: DownlineTreeviewItem[]): void {
this.rows = [];
downlineItems.forEach(downlineItem => {
const rec = downlineItem;
let parent = downlineItem.parent;
let valueSelected: any = null;
if (parent.item != null && !parent.item.children.some(ele => ele.checked !== true)) {
valueSelected = parent.item.value;
parent = parent.parent;
while (!isNil(parent)) {
if (parent.item != null && !parent.item.children.some(ele => ele.checked !== true)) {
valueSelected = parent.item.value;
}
parent = parent.parent;
}
} else {
valueSelected = downlineItem.item.value;
}
if (!this.rows.some(ele => isEqual(ele, valueSelected)))
this.rows.push(valueSelected);
});
}
any update for that above issue how I get parent id without selecting child?
For the past 2 years, people are complaining about this issue. Don't think it's going to be resolved soon. It's time to look for another package that supports this functionality.