We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Expanding tree path to selected node

Hi

I want to expand tree from root to selected node. According to documentation ensureVisible function should handle this but it does not work.
Also expandAll with parameters is not working. I can expand all nodes in tree using expandAll without params, but according to documentation I can pass array of nodes.
Still does not work.

In my code I use code like below:
this.$refs.treeView.ensureVisible(nodeId);
Can You solve my problem?

1 Reply

CI Christopher Issac Sunder K Syncfusion Team July 18, 2019 12:32 PM UTC

Hi Konrad, 

Greetings from Syncfusion support. 

We have checked with your requirement. The problem might occurs due to any of the below, 

  1. In the expandAll and ensureVisible, you might have passed the node ids other than string arrays (Ex. Integer) but we have to pass it as string arrays.
  2. We can’t expand a tree node (may be child) when the node elements is not created in DOM. By default, the child node elements will be created on demand while expanding the parent node.

We have prepared a sample for your requirement. Here is the code for your reference, 

onClick: function (args) { 
    //expand the nodes 16 - MP3 Albums, 21 - More in Music 
    this.$refs.tree1.expandAll(['16', '21']); 
    //Scroll the node into view - Jazz 
    this.$refs.tree1.ensureVisible('20'); 
} 

Please refer the below sample, 

Please get back to us if you are facing the issue still. 

Thanks,
Christo 



Loader.
Live Chat Icon For mobile
Up arrow icon