Set inital nodes collapsed or expaned

Hi,

I'm using your diagram hierachical tree


But I need set some nodes expaned or collapsed.

In node default function, I set  node.isExpanded true or false, but it always is expaned when diagram is load

Also, in diagram event click... how can I detect if I done click on node or connecotr? I need an event when I click on node...

Thanks



4 Replies 1 reply marked as answer

GG Gowtham Gunashekar Syncfusion Team February 11, 2021 03:00 PM UTC

Hi Manolo, 
 
We have added a sample link to demonstrate how to render some nodes in collapsed state in the layout diagram and added a click event to notify the clicked node 
 
Code snippet: 
public created(){ 
 
    for(var i=0;i<this.diagram.nodes.length;i++){ 
       if((this.diagram.nodes[i].shape as TextModel).content==="Hierarchical Tree"  
       || (this.diagram.nodes[i].shape as TextModel).content==="Management"){ 
      this.diagram.nodes[i].isExpanded= false; 
    } 
    } 
    this.diagram.dataBind(); 
   
 
} 
 
 
Regards, 
Gowtham 
 


Marked as answer

MC Manolo Capdevila February 11, 2021 05:18 PM UTC

Hi,

In your example, all nodes are expanded and your code indicate that must be collapsed.

Also, I get the data by a service, and these data are not loaded in created event.

I try set

this.diagram.nodes[i].isExpanded= false;

in dataLoaded event, but then I can't call diagram.dataBind()

Thanks




GG Gowtham Gunashekar Syncfusion Team February 12, 2021 03:27 PM UTC

Hi Manolo, 
 
Reported Issue : While set the node's isExpanded property true at initial rendering unwanted scroll is take placed 
 
We can reproduce the issue and confirmed this as a defect. We have logged a defect report for this issue. We will fix this issue and provide the patch on 2nd March ,2021 weekly patch release.    
 
 
    
Regards,  
Gowtham   
 



GG Gowtham Gunashekar Syncfusion Team March 3, 2021 11:12 AM UTC

Hi Manolo, 

We have fixed the reported issue and included it in our patch release (v18.4.46) which is rolled out successfully.        
        
Please upgrade to the latest version packages to resolve this issue.              

Regards,  
Gowtham 
1

Loader.
Up arrow icon