One Expand Another Collapse

Hi,

Our requirement is when I expand any parent node the other node should be collapse by default.


1 Reply

IL Indhumathy Loganathan Syncfusion Team March 23, 2022 12:51 PM UTC

Hi Nagendra, 
 
Greetings from Syncfusion support. 
 
You can collapse all the other parent nodes using collapseAll method in nodeExpanding event. Please check the below code snippet. 
  
[app.component.html] 
<ejs-treeview 
  id="default" 
  #treevalidate 
  [fields]="field" 
  (nodeExpanding)="nodeExpanding($event)" 
  [cssClass]="cssClass" 
></ejs-treeview> 
 
[app.component.ts] 
public nodeExpanding(args: NodeSelectEventArgs): void { 
  if (args.node.classList.contains('e-level-1')) { 
    this.tree.collapseAll(); 
  } 
} 
 
 
Please let us know if you need any further assistance. 
 
Regards, 
Indhumathy L 


Loader.
Up arrow icon