How to build a tree after nodes are classified

Viewed 38

There are some data. Each data has attributes such as parentId, Id, and type.

After node.parentId=parentNode.id is constructed, a tree is mounted to a virtual root node. That is the actual data is the array of the level-1 node. The preceding steps are not difficult.

The difficulties are as follows:

  1. Classify data by type.

  2. Create a virtual tree node for each category and mount it to a virtual root node.

  3. The real data under the virtual node of type also needs to be constructed based on the parent-child relationship, and the current node recursively moves up the tree to the root node.

  4. During upward recursion, if node data does not belong to this type, the data needs to be displayed. In this case, the readonly flag is added.

0 Answers
Related