Hi Ashmitha, it is possible to restore the structure of expanded Tree nodes after a refresh, but it requires manually managing the expanded/collapsed state, because the Mendix Tree Node widget does not preserve state by default after a refresh or object change.
1. Add a Boolean Attribute for State Tracking
Add an attribute like "isExpanded" (Boolean) to your TreeNode entity.
Use this to track whether each node is currently expanded.
2. Use OnClick Events
When a node is expanded or collapsed, set the "isExpanded" attribute accordingly via a microflow or nanoflow.
3. Before Refresh, Save Current State
In your logic (before calling Change Object), capture the current "isExpanded" states.
After the refresh, rebind the data, and the TreeNode widget will read the "isExpanded" state from the object and reflect the UI accordingly.
To retain expanded tree nodes after refresh, store the expanded state in a Boolean attribute (isExpanded) on each node. Update this attribute when a node is expanded/collapsed. After refreshing the tree data, bind the widget to this attribute so it reflects the previous expansion state.
I hope this one helps you! :)