Method and system for operating tree structure
By generating unique IDs for nodes of the tree structure and cache their information, the problem of inability to restore in situ and frequent data requests after merge is solved, and efficient tree structure management and rapid response are achieved.
Patent Information
- Application Number
- CN202510714955.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2025-07-01
- Estimated Expiration
- 2045-05-30
AI Technical Summary
The prior art cannot be restored on site after the merger of the tree structure. Expanding nodes requires re-requesting data, and lacking node caches, resulting in a decline in user experience and waste of server resources.
By creating a unique ID generator, each root node and its children are assigned a unique identity, and combined with the basic information and parent-child relationship of the root node, these data are encapsulated into node objects and stored in the cache hash table, realizing rapid retrieval and access of node information. When the user operates, only local rendering updates are performed on the current node and its children to avoid global re-rendering.
It realizes in-situ restoration of the tree structure, reduces the burden of data requests and rendering, improves response speed and user experience, and optimizes the dynamic management of the tree structure.
Smart Images

Figure CN120234084A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of in-situ restoration of tree structures, and particularly to a method and system for operating tree structures. Background Art
[0002] With the development of technologies in the field of computer interface design, tree structure display technologies have emerged. Due to their intuitive hierarchical display and parent-child relationship representation, tree structures are widely used in user interface design to organize and display hierarchical data, such as file systems, organizational charts, etc.
[0003] In traditional tree structure processing methods, the display and operation of nodes are usually based on their hierarchical positions in the tree. Users can expand or collapse the child items of a node by clicking the "+" or "-" sign next to the node. However, these operations usually result in the re-rendering of the entire tree structure. Especially when performing a restoration operation after merging nodes, the system often fails to maintain the expansion information of the original nodes and needs to reload the data.
[0004] However, the current tree structure display methods or traditional methods have some technical problems. Specifically, most tree structures are re-rendered when performing a restoration operation after merging and cannot maintain the expansion information of the original nodes. For example, existing toolkits such as jquery-ztree can expand nodes freely but cannot achieve the merging of nodes at the same level. Patent technologies such as CN103793135B allow node merging but cannot be restored; CN118377473A allows nodes to be expanded freely but cannot achieve the merging of nodes at the same level; CN101741708A allows the jump merging of child nodes, but cannot be restored after merging, and the child nodes do not have an expanded state; CN102662939B only provides hierarchical display and does not involve merging; CN102841891A only provides a sorting function and does not support merging. These limitations lead to a decline in user experience and a waste of server resources because each time a node is expanded, it requires re-rendering and initiating a server-side request, and nodes with duplicate information in the tree are not cached and will be requested again. Summary of the Invention
[0005] This application provides a method and system for operating a tree structure, aiming to solve the problems in the prior art that it cannot be restored in-situ after merging, re-requesting data is required to expand nodes, and there is a lack of node caching.
[0006] In a first aspect, a method for operating a tree structure, the method includes:
[0007] Create a unique ID generator, obtain the root node data, where the root node data includes the root node basic information and the parent-child relationship of the root node; create a unique ID for the root node through the unique ID generator, and package the unique ID and the root node information into a node type; store the root node information, the array of the root node's child nodes, and the identifier of the root node in the cache;
[0008] In response to the user's input to expand a node, obtain the current node ID; query the current node ID in the cache and filter out the child node information that has not been cached; request the child node information of the uncached information and place it in a node wrapper, and output the child node structure; establish the connection relationship between the current node and the child nodes; and call the renderer of itself through the current node to perform re-rendering, where the re-rendering only re-renders the current node and the child nodes and updates the expansion state of the current node;
[0009] In response to the user's input to merge nodes, start traversing from the root node, and place each layer of child nodes in a group node generator for classification, and output n group nodes; establish the relationship between the current node and the group nodes; recursively traverse the nodes in each group node until there are no group nodes;
[0010] In response to the user's input to collapse a node, obtain the current node, update the expansion state of the current node to "close", and call the node renderer of itself to update the user interface;
[0011] In response to the user's input to turn to the non-merged state, start recursive traversal from the root node, extract its own child nodes from each group node, flatten the own child nodes into an array structure, place it in a node wrapper, and output the child node structure; establish the connection between the child nodes and the current node; and continue to traverse the child nodes downward until there are no child nodes.
[0012] In the above solution, optionally, the creating a unique ID generator and obtaining the root node data includes:
[0013] Use an algorithm based on timestamp and random number as the unique ID generator. When adding a new node, the system automatically generates a UUID for each node as the unique ID; at the same time, the system obtains the hierarchical structure of the nodes from the database, including the node name, description, and sub-task list, and packages this information together with the unique ID into a node object and stores it in the hash table cache in the memory.
[0014] In the above solution, optionally, the responding to the user's input to expand a node includes:
[0015] When the user clicks the '+' sign next to a target node, the system obtains the ID of the target node and queries the child node information in the cache; if the child nodes are not cached, the system sends a request to the server to obtain the child node data and updates the node wrapper; the system dynamically generates a list of child nodes on the user interface and updates the expansion status of the folder node to 'expanded'.
[0016] In the above solution, optionally, the responding to the user's input for merging nodes includes:
[0017] After the user selects the 'Merge' view option, the system recursively traverses from the root node, classifies the nodes using the group node generator, and displays them as a collapsible / expandable group node on the user interface; this process is repeated recursively until all nodes are processed, and finally a merged organizational structure diagram is presented on the interface.
[0018] In the above solution, optionally, the responding to the user's input for collapsing a node includes:
[0019] When the user clicks the '-' sign next to a node, the system obtains the ID of the current node, calls the node renderer, and only updates the interface for this node and its child nodes, hiding the content of the sub-chapters.
[0020] In the above solution, optionally, the conversion to the non-merged state includes:
[0021] When the user selects the 'Expand' button or option, the system recursively processes from the root node, flattens and expands the nodes in each group node, and places them in the node wrapper; the system re-establishes the connection between each child node and the parent node on the user interface and updates the display status of the child nodes; this process is repeated recursively until all child nodes are expanded, and a node classification tree in the non-merged state is presented on the interface.
[0022] In a second aspect, a system for operating a tree structure, the system includes:
[0023] Initialization module: used to create a unique ID generator, obtain the root node data, where the root node data includes the root node basic information and the parent-child relationship of the root node; create a unique ID for the root node through the unique ID generator, package the unique ID and the root node information into a node type; store the root node information, the array of the root node's child nodes, and the identifier of the root node in the cache;
[0024] Expand Node Module: Used to respond to the user's expand node input, obtain the current node ID; query the current node ID in the cache and filter out the un-cached child node information; request the child node information of the un-cached information and put it into the node wrapper, output the child node structure; establish the connection relationship between the current node and the child nodes; and call its own renderer through the current node for re-rendering, where the re-rendering only re-renders the current node and the child nodes and updates the expand state of the current node.
[0025] Merge Node Module: Used to respond to the user's merge node input, traverse from the root node, classify each layer of child nodes in the group node generator, and output n group nodes; establish the relationship between the current node and the group nodes; recursively traverse the nodes in each group node until there are no group nodes left.
[0026] Collapse Node Module: Used to respond to the user's collapse node input, obtain the current node, update the expand state of the current node to "close", and call its own node renderer to update the user interface.
[0027] Convert to Non-Merge Module: Used to respond to the user's convert to non-merge state input, recursively traverse from the root node, extract its own child nodes from each group node, flatten the own child nodes into an array structure, put it into the node wrapper, and output the child node structure; establish the connection between the child nodes and the current node; and continue to traverse the child nodes downward until there are no child nodes.
[0028] In a third aspect, a computer device includes a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:
[0029] Create a unique ID generator, obtain the root node data, where the root node data includes the root node basic information and the parent-child relationship of the root node; create a unique ID for the root node through the unique ID generator, and package the unique ID and the root node information into a node type; store the root node information, the array of the root node's child nodes, and the identifier of the root node in the cache.
[0030] Respond to the user's expand node input, obtain the current node ID; query the current node ID in the cache and filter out the un-cached child node information; request the child node information of the un-cached information and put it into the node wrapper, output the child node structure; establish the connection relationship between the current node and the child nodes; and call its own renderer through the current node for re-rendering, where the re-rendering only re-renders the current node and the child nodes and updates the expand state of the current node.
[0031] In response to the user's input for merging nodes, start traversing from the root node. Place the child nodes of each layer into a group node generator for classification, and output n group nodes; establish a relationship between the current node and the group nodes; recursively process the nodes in each group node until there are no more group nodes;
[0032] In response to the user's input for collapsing nodes, obtain the current node, update the expansion state of the current node to "close", and call the node renderer of itself to update the user interface;
[0033] In response to the user's input for changing to a non-merging state, start recursing from the root node. Extract its own child nodes from each group node, flatten the said own child nodes into an array structure, place them into a node wrapper, and output a child node structure; establish a connection between the said child nodes and the current node; and continue to traverse the said child nodes downward until there are no more child nodes.
[0034] In a fourth aspect, a computer program product includes a computer program / instructions, and when the computer program / instructions are executed by a processor, the following steps are implemented:
[0035] Create a unique ID generator, obtain root node data, where the root node data includes root node basic information and the parent-child relationship of the root node; create a unique ID for the root node through the unique ID generator, package the unique ID and root node information into a node type; store the root node information, the array of child nodes of the root node, and the identifier of the root node in a cache;
[0036] In response to the user's input for expanding nodes, obtain the current node ID; query the current node ID in the cache and filter out the child node information that has not been cached; request the child node information that has not been cached and place it into a node wrapper, and output a child node structure; establish a connection relationship between the current node and the child nodes; and call the renderer of itself through the current node for re-rendering, where the re-rendering only re-renders the current node and the child nodes and updates the expansion state of the current node;
[0037] In response to the user's input for merging nodes, start traversing from the root node. Place the child nodes of each layer into a group node generator for classification, and output n group nodes; establish a relationship between the current node and the group nodes; recursively process the nodes in each group node until there are no more group nodes;
[0038] In response to the user's input for collapsing nodes, obtain the current node, update the expansion state of the current node to "close", and call the node renderer of itself to update the user interface;
[0039] In response to the user's input to change to the non - merged state, start recursion from the root node, extract its own child nodes in each group node, flatten the said own child nodes into an array structure, place them in a node wrapper, and output the child node structure; establish a connection between the said child nodes and the current node; and continue to traverse the said child nodes downward until there are no more child nodes.
[0040] Compared with the prior art, the present application has at least the following beneficial effects:
[0041] Based on further analysis and research of the problems in the prior art, the present application realizes that the prior art has problems such as being unable to restore in - place after merging, needing to re - request data when expanding nodes, and lacking node caching. By creating a unique ID generator, a unique identifier is assigned to each root node and its child nodes, and combined with the basic information and parent - child relationship of the root node, this data is encapsulated as a node object and stored in a cache hash table, achieving fast retrieval and access of node information. When the user expands a node, the system queries in the cache and requests information of non - cached child nodes, and only performs local rendering updates on the current node and its child nodes, avoiding global re - rendering and improving the response speed. At the same time, this solution supports the user's input to merge nodes. The child nodes are classified by a group node generator, and each group node is recursively processed until there are no more group nodes to simplify the view. When the user collapses a node, the system updates the node state and locally updates the interface. For the input to change to the non - merged state, the system recursively expands the child nodes in each group node, flattens them into an array structure, and re - establishes the parent - child connection. This method not only solves the limitations of the prior art but also optimizes the dynamic management of the tree structure and the user interaction experience, achieving efficient data processing and fast view switching. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] Figure 1 It is a flowchart showing the method of operating a tree structure provided by an embodiment of the present application;
[0043] Figure 2 It is a general flowchart showing the method of operating a tree structure provided by an embodiment of the present application;
[0044] Figure 3 It is a flowchart showing the initialization and the process of the user expanding a node provided by an embodiment of the present application;
[0045] Figure 4 It is a flowchart showing the process of the user's merge operation provided by an embodiment of the present application;
[0046] Figure 5 It is a flowchart showing the process of the user's restore merge operation provided by an embodiment of the present application;
[0047] Figure 6One of the schematic diagrams of the operation interface of the method for operating a tree structure provided by an embodiment of the present application;
[0048] Figure 7 Another schematic diagram of the operation interface of the method for operating a tree structure provided by an embodiment of the present application;
[0049] Figure 8 Another schematic diagram of the operation interface of the method for operating a tree structure provided by an embodiment of the present application;
[0050] Figure 9 Another schematic diagram of the operation interface of the method for operating a tree structure provided by an embodiment of the present application;
[0051] Figure 10 Another schematic diagram of the operation interface of the method for operating a tree structure provided by an embodiment of the present application;
[0052] Figure 11 Another schematic diagram of the operation interface of the method for operating a tree structure provided by an embodiment of the present application;
[0053] Figure 12 Another schematic diagram of the operation interface of the method for operating a tree structure provided by an embodiment of the present application;
[0054] Figure 13 Internal structure diagram of a computer device in an embodiment. Detailed implementation manners
[0055] In order to make the objectives, technical solutions and advantages of the present application more clear and understandable, the present application will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0056] In one embodiment, as Figure 1 shown, a method for operating a tree structure is provided, including the following steps:
[0057] Create a unique ID generator, obtain root node data, where the root node data includes root node basic information and the parent-child relationship of the root node; create a unique ID for the root node through the unique ID generator, and package the unique ID and root node information into a node type; store the root node information, the array of child nodes of the root node and the identifier of the root node in a cache;
[0058] In response to the user's input to expand a node, obtain the current node ID; query the current node ID in the cache and filter out the child node information that has not been cached; request the child node information that has not been cached and place it in a node wrapper, and output the child node structure; establish a connection relationship between the current node and the child nodes; and call the renderer of itself through the current node to perform re-rendering, where the re-rendering only re-renders the current node and the child nodes and updates the expansion state of the current node;
[0059] In response to the user's input to merge nodes, start traversing from the root node, place the child nodes at each level in a group node generator for classification, and output n group nodes; establish a relationship between the current node and the group nodes; recursively traverse the nodes in each group node until there are no group nodes left;
[0060] In response to the user's input to collapse a node, obtain the current node, update the expansion state of the current node to "close", and call the node renderer of itself to update the user interface;
[0061] In response to the user's input to switch to the non-merged state, perform recursion from the root node, extract its own child nodes from each group node, flatten the own child nodes into an array structure, place it in a node wrapper, and output the child node structure; establish a connection between the child nodes and the current node; and continue to traverse the child nodes downward until there are no child nodes.
[0062] In this embodiment, the creation of the unique ID generator and the acquisition of the root node data include:
[0063] Use an algorithm based on timestamp and random number as the unique ID generator. When adding a new node, the system automatically generates a UUID for each node as the unique ID; at the same time, the system obtains the hierarchical structure of the nodes from the database, including the node name, description, and sub-task list, and encapsulates this information together with the unique ID into a node object and stores it in the hash table cache in memory.
[0064] In this embodiment, the response to the user's input to expand a node includes:
[0065] The user clicks the "+" sign next to a target node, the system obtains the ID of the target node and queries the child node information in the cache; if the child nodes are not cached, the system sends a request to the server to obtain the child node data and updates the node wrapper; the system dynamically generates a list of child nodes on the user interface and updates the expansion state of the folder node to "expanded".
[0066] In this embodiment, the response to the user's input to merge nodes includes:
[0067] After the user selects the "Merge" view option, the system starts a recursive traversal from the root node, classifies the nodes using the group node generator, and displays them as an expandable / collapsible group node on the user interface; this process is carried out recursively until all nodes are processed, and finally a merged organizational structure diagram is displayed on the interface.
[0068] In this embodiment, the responding to the user's collapsing node input includes:
[0069] The user clicks the "-" sign next to a node, the system obtains the ID of the current node, calls the node renderer, and only updates the interface for this node and its child nodes, hiding the content of the sub-chapters.
[0070] In this embodiment, the converting to the non-merged state includes:
[0071] The user selects the "Expand" button or option, the system starts a recursive process from the root node, flattens and expands the nodes in each group node, and places them in the node wrapper; the system re-establishes the connection between each child node and the parent node on the user interface and updates the display state of the child nodes; this process is carried out recursively until all child nodes are expanded, and a non-merged node classification tree is displayed on the interface.
[0072] In this embodiment, by creating a unique ID generator, a unique identifier is assigned to each root node and its child nodes, and combined with the basic information and parent-child relationship of the root node, this data is encapsulated as a node object and stored in the cache hash table, realizing the fast retrieval and access of node information. When the user expands a node, the system queries in the cache and requests information of non-cached child nodes, and only performs local rendering updates on the current node and its child nodes, avoiding global re-rendering and improving the response speed. At the same time, this solution supports the user's merged node input, classifies the child nodes through the group node generator, and recursively processes each group node until there are no group nodes left to simplify the view. When the user collapses a node, the system updates the node state and locally updates the interface. For the input of converting to the non-merged state, the system recursively expands the child nodes in each group node, flattens them into an array structure, and re-establishes the parent-child connection. This method not only solves the limitations of the prior art, but also optimizes the dynamic management of the tree structure and the user interaction experience, realizing the efficient processing of data and the fast switching of views.
[0073] In one embodiment, as Figure 2 shown, a method for operating a tree structure is provided, constructing two tree data structures A and B, and a cache hash table (including the information of the node itself and the parent-child relationship).
[0074] As Figure 3 and Figure 6As shown, create a unique ID generator, obtain the root node data (including the basic information of the current node and the parent-child relationship of this node), create a unique ID for the root node, wrap the unique ID and the root node information into a node type, and store the root node information, the pns array of the root node, and the identifier pn of the root node in the cache.
[0075] In one embodiment, as Figure 7 shown, click the "+" button on the right side of the root node, and 9 child nodes will be immediately expanded on the right side of this node, and the detailed information of these child nodes will be displayed. The working principle is as follows:
[0076] Obtain the current node ID, query this ID in the cache and filter out the information of the child nodes that have not been cached, request the information of the child nodes with uncached information, put it into the node wrapper, output the child node structure. This step of operation will not repeatedly obtain the cached node information. Establish a connection relationship between the current node and the child nodes. The current node calls its own renderer for re-rendering. This step of operation only re-renders the current node and the child nodes, and will not perform a global re-rendering, and update the expansion state of the current node.
[0077] As Figure 4 and Figure 8 shown, perform a merge operation in the non-merged state (convert from tree structure A to tree structure B). For the user to perform the merge operation, the 9 nodes on the right side of the original root node will be converted into group nodes according to the merge strategy and immediately displayed on the interface. The working principle is as follows: Start traversing from the root node, put each layer of child nodes into the group node generator for classification, output n group nodes, establish a relationship between the current node and the group nodes, and recursively traverse the nodes in each group node until there are no group nodes.
[0078] Closing nodes in the merge / non-merge state includes: obtaining the current node, updating the node expansion state to "close", calling its own node renderer, and converting the merge state to the non-merge state (restore in place, convert from structure B to structure A, without repeated data pulling);
[0079] In one embodiment, as Figure 5 、 Figure 9 and Figure 10 shown, switch the merge strategy in the upper left corner to the "non-merge" state (i.e., merge restoration), the group nodes will immediately become ordinary nodes, and the expanded child nodes of the group nodes will still maintain their original expansion state. The working principle is as follows: Recursively start from the root node, extract its own children nodes from each group node, flatten them into an array structure, put it into the node wrapper, output the child node structure, establish a connection between these child nodes and the current node, and the child nodes continue to traverse down until there are no child nodes.
[0080] AsFigure 11 As shown, a diagram in the merged state is provided according to a certain strategy, such as Figure 12 As shown, when changing the merge state in the upper left corner and restoring it to the unmerged state, the expanded merged nodes remain in their original expanded state when restored, only the child nodes are changed.
[0081] This embodiment effectively reduces the burden on the server when processing tree structure merging and restoration operations. First, the solution realizes that there is no need to re-request server data when performing the restoration operation, reducing the need for network communication and server processing. Second, when the merge operation needs to be restored, the solution only re-renders the group nodes instead of the entire tree structure, which not only improves the rendering efficiency but also optimizes the user experience. In addition, for the already expanded nodes, when they are closed and then expanded, the solution can utilize the data in the cache, avoiding unnecessary server requests, thus improving the response speed of the operation. Finally, for the nodes with duplicate information, the solution can intelligently identify and reuse the existing data, avoiding duplicate data requests and further improving the performance.
[0082] In one embodiment, a system for operating a tree structure is provided, including:
[0083] Initialization module: used to create a unique ID generator, obtain root node data, where the root node data includes root node basic information and the parent-child relationship of the root node; create a unique ID for the root node through the unique ID generator, wrap the unique ID and root node information into a node type; store the root node information, the array of child nodes of the root node, and the identifier of the root node in the cache;
[0084] Expand node module: used to respond to the user's expand node input, obtain the current node ID; query the current node ID in the cache and filter out the un-cached child node information; request the child node information of the un-cached information and put it into the node wrapper, output the child node structure; establish the connection relationship between the current node and the child nodes; and call its own renderer through the current node for re-rendering, where the re-rendering only re-renders the current node and the child nodes and updates the expand state of the current node;
[0085] Merge node module: used to respond to the user's merge node input, start traversing from the root node, put each layer of child nodes into the group node generator for classification, output n group nodes; establish the relationship between the current node and the group nodes; recursively traverse the nodes in each group node until there are no group nodes left;
[0086] Collapse node module: used to respond to the user's collapse node input, obtain the current node, update the expand state of the current node to "close", and call its own node renderer to update the user interface;
[0087] Transfer to non-merged module: Used to respond to the user's input of the transfer to non-merged status, recursively start from the root node, extract its own child nodes in each group node, tile the own child nodes into an array structure, place them in a node wrapper, and output the child node structure; establish a connection between the child nodes and the current node; and continue to traverse the child nodes downward until there are no more child nodes.
[0088] For the specific implementation content of each module, reference can be made to the limitations on the method of operating the tree structure in the above text, which will not be elaborated here.
[0089] In one embodiment, a computer device is provided. This computer device can be a server, and its internal structure diagram can be as Figure 13 shown. The computer device includes a processor, a memory, and a network interface connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities, and the network interface is used to communicate with external terminals through a network connection. The computer device loads and runs a computer program to implement the above method of operating a tree structure.
[0090] Those skilled in the art can understand that Figure 13 the structure shown in
[0091] is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0092] The technical features of the above embodiments can be combined arbitrarily. For the sake of brevity of description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered as the scope described in this specification.
Claims
1. A method for operating a tree structure, characterized in that The method includes: Create a unique ID generator, obtain root node data, where the root node data includes root node basic information and the parent-child relationship of the root node; create a unique ID for the root node through the unique ID generator, and package the unique ID and root node information into a node type; store the root node information, the array of the root node's child nodes, and the identifier of the root node in the cache; In response to the user's input to expand a node, obtain the current node ID; query the current node ID in the cache and filter out the child node information that has not been cached; request the child node information of the uncached information and place it in a node wrapper, and output the child node structure; establish a connection relationship between the current node and the child nodes; and call the renderer of itself through the current node for re-rendering, where the re-rendering only re-renders the current node and the child nodes and updates the expansion state of the current node; In response to the user's input to merge nodes, start traversing from the root node, place the child nodes at each level in a group node generator for classification, and output n group nodes; establish a relationship between the current node and the group nodes; recursively traverse the nodes in each group node until there are no group nodes left; In response to the user's input to collapse a node, obtain the current node, update the expansion state of the current node to "close", and call the node renderer of itself to update the user interface; In response to the user's input to switch to the non-merged state, start recursively from the root node, extract its own child nodes from each group node, flatten the own child nodes into an array structure, place it in a node wrapper, and output the child node structure; establish a connection between the child nodes and the current node; and continue to traverse the child nodes downward until there are no child nodes.
2. The method according to claim 1, characterized in that, The creation of the unique ID generator and obtaining the root node data includes: Use an algorithm based on timestamp and random number as the unique ID generator. When adding a new node, the system automatically generates a UUID for each node as the unique ID; at the same time, the system obtains the hierarchical structure of the nodes from the database, including node names, descriptions, and sub-task lists, and packages this information together with the unique ID into a node object and stores it in the hash table cache in memory.
3. The method according to claim 1, characterized in that The response to the user's input to expand a node includes: When the user clicks the "+" sign next to a target node, the system obtains the ID of the target node and queries the child node information in the cache; if the child nodes are not cached, the system sends a request to the server to obtain the child node data and updates the node wrapper; the system dynamically generates a list of child nodes on the user interface and updates the expansion state of the folder node to "expanded".
4. The method according to claim 1, characterized in that, The response to the user's input to merge nodes includes: After the user selects the "merge" view option, the system starts recursive traversal from the root node, classifies the nodes using a group node generator, and displays them as an expandable / collapsible group node on the user interface; this process is recursively carried out until all nodes are processed, and finally a merged organizational structure diagram is displayed on the interface.
5. The method according to claim 1, characterized in that The response to the user's input to collapse a node includes: When the user clicks the "-" sign next to a node, the system obtains the ID of the current node, calls the node renderer, and updates only the interface of this node and its child nodes, hiding the content of the sub-chapters.
6. The method according to claim 1, wherein The response to the user's non-merging state includes: The user selects the "Expand" button or option. The system recursively processes from the root node, flattens and expands the nodes in each group node, and places them in the node wrapper. The system re-establishes the connection between each child node and the parent node on the user interface and updates the display state of the child nodes. This process is repeated recursively until all child nodes are expanded, and a non-merging state node classification tree is displayed on the interface.
7. A system for operating a tree structure, characterized in that, The system includes: Initialization module: used to create a unique ID generator, obtain the root node data, where the root node data includes the root node basic information and the parent-child relationship of the root node; create a unique ID for the root node through the unique ID generator, wrap the unique ID and the root node information into a node type; store the root node information, the array of child nodes of the root node, and the identifier of the root node in the cache; Expand node module: used to respond to the user's expand node input, obtain the current node ID; query the current node ID in the cache and filter out the un-cached child node information; request the child node information of the un-cached information and place it in the node wrapper, output the child node structure; establish the connection relationship between the current node and the child nodes; and call its own renderer through the current node for re-rendering, where the re-rendering only re-renders the current node and the child nodes and updates the expand state of the current node; Merge node module: used to respond to the user's merge node input, traverse from the root node, place the child nodes of each layer in the group node generator for classification, and output n group nodes; establish the relationship between the current node and the group nodes; recursively process the nodes in each group node until there are no group nodes; Collapse node module: used to respond to the user's collapse node input, obtain the current node, update the expand state of the current node to "close", and call its own node renderer to update the user interface; Convert to non-merging module: used to respond to the user's convert to non-merging state input, recursively process from the root node, extract its own child nodes from each group node, flatten the own child nodes into an array structure, place it in the node wrapper, and output the child node structure; establish the connection between the child nodes and the current node; and continue to traverse the child nodes downward until there are no child nodes.
8. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, it implements the steps of the method described in any one of claims 1 to 6.
9. A computer program product comprising a computer program / instructions, characterized in that, When the computer program / instructions are executed by the processor, it implements the steps of the method described in claims 1-6.
Citation Information
Patent Citations
Method, device and system for storing data
CN101741708A
Tree-form data structure displaying method and system
CN102662939B
Method and device for ordering tree structure nodes, and enquiry system
CN102841891A
User Interface Tree Structure Display Method and System
CN103793135B
Tree control construction method, system and equipment and storage medium
CN118377473A