Treeview nodes collapse after being refreshed
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']
}
},
SIGN IN To post a reply.
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.
Regards,
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.
Regards,
Shameer Ali Baig S.
SIGN IN To post a reply.
- 3 Replies
- 4 Participants
-
AM Adam Moroff
- Aug 16, 2019 04:32 AM UTC
- Nov 13, 2020 08:34 AM UTC