Hi
I'm working with zTree and I've encountered an issue with preserving the tree's state.
I want to show a confirmation dialog before a node is clicked, and I've successfully implemented this using the BeforeClick event in zTreeStructureCallbackList .
The problem is that whenever the condition variable changes, the entire tree collapses, resetting to its initial state.
I would like to know how to maintain the expanded and selected state of the tree while still triggering the confirmation dialog.
Here's a simplified version of my code:
Both methods will yield the same result
Thanks
Dear @Hirotaka Onishi .
You need to:
Would you like to share your oml files? I can help you more in details.
Hi @ndy
I don't know how I capture and restore the tree state.
This is a simple sample.
IsEditing variable is a condition.
If IsEditin is true, confirm window is shown.
Would you like to give me some records, @Hirotaka Onishi ?
If you want to learn more about Ztree you can have a look in the Documentation and demo.Ztree DOCZtree DemoHope this helps !
@ndy
This is a data sample
Tree is like this
I have attached a recording of the screen activity.
Thank you
Hi, @Hirotaka Onishi . You can refer the modified oml to find the error.
Hi, @ndy
I have checked the oml, but the issue remains unresolved.
In your oml, All nodes are expanded by default.
Even when I collapse nodes and toggle the IsEditing switch, all nodes expand again.
My goal is to preserve the state of the tree before toggling the switch.
Although it may not be the most ideal solution, I've managed to resolve the issue.
I've added a Boolean flag named "IsConfirm" to the Init function within the zTreeReactive's Scripts/zTree.
I've also introduced a ClientAction to zTreeReactive to set the value of IsConfirm.
Lastly, I've configured the BeforeClick function body as follows:
Thank you all for your assistance.