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

Treeview nodes collapse after being refreshed

Thread ID:

Created:

Updated:

Platform:

Replies:

146727 Aug 16,2019 04:32 AM UTC Aug 19,2019 11:42 AM UTC Vue 1
loading
Tags: Treeview
Adam Moroff
Asked On August 16, 2019 04:32 AM UTC

Hello
I have a Treeview control which is populated from a Vuex store via a getter in a computed property.  The problem is when the computed property is fired the treeview is refresh but all the nodes are collapsed.  Ive tried using  the enablePersistence property but it doesnt work.  My code is below.  any help is appreciated.

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

computed: {
fields() {
return {
id: 'id',
text: 'name',
child: 'pages',
dataSource: this.$store.getters['notebookStore/getNotebook'].sections
}
},
notebook() {
return this.$store.getters['notebookStore/getNotebook']
}
},

     

Ashokkumar Balasubramanian [Syncfusion]
Replied On August 19, 2019 11:42 AM UTC

Hi Adam Moroff, 
 
Good day to you. 
 
We have validated your requirements and prepared a sample according to that. When the computed property is fired, the overall component will be re rendered. So, if you want to maintain the expanded state, you have to update the state of the corresponding node in the nodeExpanded event using the following code snippet. 
 
        onExpand(args) { 
            this.$store.dispatch("onExpand", args.nodeData); 
        } 
 
onExpand(state, data) { 
            state.treeDataSource = state.treeDataSource.filter( 
                _ => (_.expanded = data.expanded) 
            ); 
        } 
 
 
Kindly check the above sample and let us know if you have any concerns. 
 
Regards, 
Ashokkumar B. 


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