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

Treeview nodes collapse after being refreshed

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.


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


3 Replies

AB Ashokkumar Balasubramanian Syncfusion Team 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. 
Ashokkumar B. 

YP Yogesh Patil November 12, 2020 05:25 AM UTC

Can I get the same solution in Angular 8.

SA Shameer Ali Baig Sulaiman Ali Baig Syncfusion Team November 13, 2020 08:34 AM UTC

Hi Yogesh, 
In the following Angular TreeView’s documentation section, we have added sample for adding new nodes in the tree node. On adding the tree node, other already expanded tree nodes will stay in expanded state. 
Can you please share us your exact requirement/problem details with EJ2 TreeView. So, we can understand and provide you the prompt solution needed. 
Please, check out the following links to know more about EJ2 TreeView component. 
Please, let us know if you need any further assistance. 
Shameer Ali Baig S. 

Live Chat Icon For mobile
Up arrow icon