10
Views
3
Comments
Solved
[zTree] Save the collapse and expand it in a session variable
Forge component by Eduardo Luís
20
Published on 03 Oct 2019

Hi!

How to store in a session variable if a given node in the tree has been expanded or collapsed and also store the id of that node?

The intention is for the user to refresh the page and the tree will be as it was before the refresh.


Thanks

Rank: #69
Solution

Hi Danilo,

To store the selected node, you can use the CallBack OnClick function, as in the image below;

To expand the specific node, it was necessary to create a custom javascript, as the component does not have one.



I added an OML with these customizations

KeepExpanded.oml

Rank: #14379

Good Morning!


Huarlem, I implemented with your suggestion. What is not happening, which may not have been clearer in my difficulty, is that the tree does not keep, if it was once collapsed or expanded.

I can do this using the node ID when building the tree and set it to the "isOpen" property. If the ID is the same as the one selected, it sets the setting I want.

Wouldn't there be a way to get the (+) or (-) element? Thus, it would not be necessary for me to click on any node to know which node will be collapsed or expanded.

As the attached image follows.

Thanks

Capturar.PNG

Rank: #14379

I found a solution.

I will use Multi_02_ClickToExpand. With that I can get the ID with the Huarlem implementation and use this JavaScript inside my onclick callback to expand or collapse that particular node in the tree.

"function (e, treeId, treeNode) {

             var zTree = $ .fn.zTree.getZTreeObj (treeId);

             zTree.expandNode (treeNode);


         } "