20
Views
8
Comments
[ZTree Reactive] zTree Reactive BeforeClidk Confirm
ztree-reactive
Reactive icon
Forge asset by Pedro Neto
Application Type
Reactive
Service Studio Version
11.54.86 (Build 63808)

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

2024-07-31 11-32-34
ndy

Dear @Hirotaka Onishi .

 You need to:

  1. Capture the state before the condition variable changes.
  2. Restore the state after the tree is re-rendered or updated.

Would you like to share your oml files? I can help you more in details.

UserImage.jpg
Hirotaka Onishi

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.

zTreeTest.oml
2024-07-31 11-32-34
ndy

Would you like to give me some records, @Hirotaka Onishi ?

2025-12-15 09-29-24
Thibaut G

If you want to learn more about Ztree you can have a look in the Documentation and demo.

Ztree DOC
Ztree Demo

Hope this helps !

UserImage.jpg
Hirotaka Onishi

@ndy 

This is a data sample

Tree is like this


I have attached a recording of the screen activity.

Thank you

recording_sample.zip
2024-07-31 11-32-34
ndy

Hi, @Hirotaka Onishi . You can refer the modified oml to find the error.

zTreeTest-ndy.oml
UserImage.jpg
Hirotaka Onishi

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. 

UserImage.jpg
Hirotaka Onishi

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.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.