ngx-treeview icon indicating copy to clipboard operation
ngx-treeview copied to clipboard

How get parent value

Open rocky-bgta opened this issue 6 years ago • 5 comments

From this treeview we only get child tree value, How I get the parent node value?

rocky-bgta avatar Aug 04 '18 16:08 rocky-bgta

@rocky-bgta I can do it from here https://leovo2708.github.io/ngx-treeview/#/advanced

curvecode avatar Aug 06 '18 08:08 curvecode

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

pirgazi avatar Aug 21 '20 10:08 pirgazi

``

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);
    });
  }

pirgazi avatar Aug 21 '20 11:08 pirgazi

any update for that above issue how I get parent id without selecting child?

balachander2812 avatar Sep 04 '20 13:09 balachander2812

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.

techiesalman avatar Jan 07 '21 07:01 techiesalman