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

checked value of child item can not be changed programatically

Open LinWang2 opened this issue 6 years ago • 2 comments

I have a ngx-treeview with decoupleChildFromParent is true, and I want to change checked and disabled attribute of child nodes programatically when I select or un-select parent node. if parent node is selected, child nodes are also changed to be seleced and disabled. if parent node is not selected, child nodes are changed to be usable only. it is so strange that disabled attribute can be changed as expected, but checked value is not ever changed. could you help me about it?

html
<ngx-treeview [config]="config" [items]="items" [itemTemplate]="itemTemplate"></ngx-treeview>
<ng-template #itemTemplate let-item="item" let-onCollapseExpand="onCollapseExpand">
                          <div class="form-inline row-item">
                            <i *ngIf="item.children" (click)="onCollapseExpand()" aria-hidden="true" class="fa" [class.fa-caret-right]="item.collapsed"
                              [class.fa-caret-down]="!item.collapsed"></i>
                            <div class="form-check">
                              <input type="checkbox" class="form-check-input" [(ngModel)]="item.checked" (ngModelChange)="onCheckboxChanged(item)" [disabled]="item.disabled"
                                 />
                              <label  class="form-check-label" >
                                {{item.text}}
                              </label>
                            </div>
                          </div>
                        </ng-template>
ts
  onCheckboxChanged(item: TreeviewItem) {
item.children.forEach(yearItem => {
        yearItem.disabled = item.checked;
        if (item.checked) {
          yearItem.checked = item.checked;
        }
      });
}

image

LinWang2 avatar Feb 21 '19 10:02 LinWang2

@LinWang2 were you able to solve this issue?

ramya0311 avatar Oct 02 '19 02:10 ramya0311

@leovo2708 is there a fix for this?

ramya0311 avatar Dec 13 '19 07:12 ramya0311