How to experiment with traversing sets and subsets by java

traverse the tree and all its child nodes

Mar.16,2021

is this question misunderstood by myself or miswritten by the subject?
well, let's say you're asking all the nodes of the traversal tree.
then the problem arises. As far as I know, the structure of the foreground and background ztree is different, or the data structure is different.
Let's say it on a case-by-case basis:
1. The data found in the background database is actually a collection of List < ZtreeNode >. As for how the collection is traversed, I think you know.
2. The tree obtained at the front desk is already a data in json format.
is as follows:
var nodes = [
{"id": 1, "name": "test1",

children: [
{ "id":3, "name":"test3"},
{ "id":4, "name":"test4"},
{ "id":5, "name":"test5"}
]

},
{"id": 2, "name": "test2"}
]
json format traversal, it is easy to get the highest node. (in reality, what is needed is more of the selected node than the tallest node.)
/ / get the current tree
var treeObj = $.fn.zTree.getZTreeObj ("tree");
/ / get the children of the node (collection)
var nodes = treeObj.getNodes () [0] .children;
/ / determine whether a node is a parent (if it is a parent, it means there are still children to continue the loop, and vice versa)
if (sNodes.length > 0) {

var isParent = sNodes[0].isParent;

}

Menu