disableNodes method it's not working for me

Is it possible for you to provide some working sample about how it does work?

I have a treeview component with checkbox selection enabled. In our scenario, each parent is treated as any other node, meaning that it can be selected without selecting any of their children.
What we want is to be able to pass an array as nodes ids and disable those, it doesn't matter if it's a leaf node or a parent node, we just need the specific nodes to be disabled.

Is that possible?

Regards,
Ernesto

5 Replies 1 reply marked as answer

SM Shalini Maragathavel Syncfusion Team May 24, 2021 07:55 AM UTC

Hi Ernesto, 

Greetings from Syncfusion support. 
                                                                                                                                         
Based on your query, we suspect that you need to disable specific nodes of the EJ2 TreeView component. You can achieve your requirement by passing the ID’s of nodes in the disableNodes method as demonstrated in the below code snippet, 
  
<div > 
  <button ejs-button id="btn" (click)="disableNode()">Disable nodes</button> 
      <ejs-treeview #defaultCheck  id="checkbox"  [fields]="field" [showCheckBox]="showCheckBox" [autoCheck]="false" ></ejs-treeview> 
</div> 
------------------------------------------------------------------------------------ 
export class AppComponent { 
  disableNode() { 
    this.treeObj.disableNodes(['21', '3', '1']); 
  } 
} 
 
In the above sample, we have disable the nodes using an external button click.

Please refer to the below sample for your reference.
 
  
Please, refer to the below links for more information on EJ2 TreeView component.  
  
  


If we have misunderstood your query, then please share us the following information to validate further on this, 

  • Please elaborate on your requirement in detail with a pictorial representation or video demonstration(If possible).
  • Please confirm us whether you are using EJ1 or EJ2 TreeView component
 
Please let us know if you need further assistance.  
  
Regards,   
Shalini M. 


Marked as answer

EY Ernesto Yoon May 27, 2021 03:00 PM UTC

Thank you Shalini M.

I see it works. My code was not working because I tried to disable the node during drawNode event.

Now I have another question, I see from your example that disableNodes is called from a button click, but I need to disable nodes after all nodes in the tree have been rendered.

Is there an event that I could use to know when all nodes finished rendered?

Regards,
Ernesto


SS Sharon Sanchez Selvaraj Syncfusion Team May 28, 2021 12:49 PM UTC

Hi Ernesto, 
 
Greetings from Syncfusion Support. 
 
We checked with your requirement to disable nodes during initial rendering and have created a sample for your reference. You can use created or dataBound event to disable the required nodes after all the nodes are rendered as per your requirement. 
 
Refer to the code snippet. 
 
 created() { 
    this.treeObj.disableNodes(['21''3''1']); 
  } 
 
 
Refer to the sample. 
 
 
 
Please get back to us if you need further assistance. 
 
Regards, 
 
Sharon Sanchez S. 



EY Ernesto Yoon June 1, 2021 11:08 PM UTC

Thank you .Sharon Sanchez S.


KR Keerthana Rajendran Syncfusion Team June 2, 2021 05:45 AM UTC

Hi Ernesto,  
 
Most welcome. We are glad to know that the provided details helped you. Please get back to us if you need further assistance. We will be happy to assist you. 
 
Regards, 
Keerthana. 


Loader.
Up arrow icon