how to disable node without disable his children

Hi all, 

How can i disable a node without disabled his children automatically ? 

I need in my app to disable a node but not the children, it's to select some category, but some parent category must not be selected to associate to an other object, some category must not be selectable.

Thx for a solution

Alexis


1 Reply

SM Shalini Maragathavel Syncfusion Team August 20, 2021 11:55 AM UTC

Hi Alexis, 

Greetings from Syncfusion support.
 
Based on your query, we suspect that you need to disable all the parent nodes in the TreeView. You can achieve your requirement by passing the parent node id’s to disableNodes method in dataBound event of TreeView component as demonstrated in the below code snippet, 
 
App.component.html 
<ejs-treeview #treeview id="listtree" (dataBound)="dataBound($event)" [fields]='listfields'></ejs-treeview> 
--------------------------------------------------------------
App.component.html
 
 
export class AppComponent { 
    public disableNodeId=[]; 
    dataBound(args){ 
        for(var i=0;i<args.data.length;i++){ 
            if(args.data[i].hasChild){ //to check whether the node has children 
                var nodeId=(args.data[i].id).toString(); 
               this.disableNodeId.push(nodeId); 
            } 
        } 
        this.treeObj.disableNodes(this.disableNodeId); 
    } 

Please find the below sample for your reference.
 
  
                 https://ej2.syncfusion.com/angular/documentation/api/treeview#databound                  
  
Please get back to us if you need further assistance.  
  

Regards, 
 
Shalini M. 


Loader.
Up arrow icon