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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

ExpandAll not working. How can I programatically expand a tree node in Vue?

Thread ID:

Created:

Updated:

Platform:

Replies:

147177 Sep 3,2019 11:58 PM UTC Sep 4,2019 05:37 PM UTC Vue 1
loading
Tags: Treeview
Adam Moroff
Asked On September 3, 2019 11:58 PM UTC

Hello
Im trying to expand a specific node in the treeview.  This is the code Im using but I cant seem to expand the node prgramatically.  Does anybody have an example of how to do this with Vue? Thanks.

Template
-----
<ejs-treeview
id="treeview"
ref="treeview"
:fields="fields"
@nodeClicked="nodeClicked"
></ejs-treeview>

Script
-----
console.log('get tree data')
let node = this.$refs.treeview.getNode('sec_1')
console.log(node)
console.log('expanding node ' + node.id)
this.$refs.treeview.expandAll([node.id])


Console
-----
get tree data
{id: "sec_1", text: "section1", parentID: null, selected: false, expanded: false, …}expanded: falsehasChildren: trueid: "sec_1"isChecked: nullparentID: nullselected: falsetext: "section1" notexpanding node sec_1

Vinoth Kumar Sundara Moorthy [Syncfusion]
Replied On September 4, 2019 05:37 PM UTC

Hi Adam, 
 
Thank you for contacting Syncfusion support. 
 
We have validated your query. You can programmatically expand a node via any of the following methods 
 
1.       Using expandAll method 
 
2.       Using expandedNodes property 
 
3.       By mapping expanded: true while field declaration 
 
We have prepared a sample to expand nodes programmatically in the nodeClicked event of the TreeView. 
 
Code Example 
nodeClicked: function(args) { 
    var node = this.$refs.tree1.getNode(args.node); 
    console.log(node); 
    //expand the nodes 
    this.$refs.tree1.expandAll([node.id]); 
    console.log("expanding node " + node.id); 
    // uncomment this to expand the selected node alone 
    // this.$refs.tree1.expandedNodes = [node.id] 
} 
 
 
Could you please check the above sample and get back to us if you need any further assistance? 
 
Regards, 
Vinoth Kumar S 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon