A. S. Bush
A. S. Bush

Reputation: 21

How to disable NodeTree (parents and children) in primeng?

This is my HTML code:

<p-tree id="tree" *ngIf="node"  [value]="node" selectionMode="null"  [(selection)]="selectedFile" (onNodeSelect)="nodeSelect($event)" (onNodeUnselect)="nodeUnselect($event)" >
                <ng-template let-node pTemplate="default" >
                  <b>{{node.data.description}}</b>
                </ng-template>
              </p-tree>

I need to disable all the tree. A disable control would be enough or replace hand pointer with a cursor pointer. Any advice? Thanks in advance!

Upvotes: 0

Views: 3074

Answers (1)

Salik Khan
Salik Khan

Reputation: 199

  • set node.selectable=false; for all the parent and child node by using recursive function

    disableRecursive(node:TreeNode){
        node.selectable = false;
        if (node.children){
            node.children.forEach( childNode => {
                this.disableRecursive(childNode);
            } );
        }
    }

Upvotes: 4

Related Questions