A method and system for manipulating tree structures
By assigning unique IDs to tree structure nodes and utilizing a cached hash table, the problems of inability to restore in place after merging and insufficient node caching are solved, enabling local rendering updates and fast response, and optimizing the dynamic management of tree structures and user interaction experience.
Patent Information
- Application Number
- CN202510714955.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-30
- Publication Date
- 2026-03-06
- Estimated Expiration
- 2045-05-30
AI Technical Summary
The existing tree structure cannot be restored in place after merging. Expanding nodes requires re-requesting data and lacks node caching, resulting in a degraded user experience and wasted server resources.
By creating a unique ID generator, a unique identifier is assigned to each root node and its child nodes. This identifier, combined with the root node's basic information and parent-child relationships, is encapsulated into node objects and stored in a cached hash table, enabling fast retrieval and access to node information. During user operations, the system queries and requests uncached child node information from the cache, performs partial rendering updates only on the current node and its child nodes, supports merging and collapsing node operations, and recursively processes grouped nodes to simplify the view.
It enables fast retrieval and access to node information, avoids global re-rendering, improves response speed, optimizes the dynamic management of the tree structure and user interaction experience, reduces network communication and server processing requirements, and improves operational efficiency and user experience.
Smart Images

Figure CN120234084B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of in-situ restoration technology of tree structures, and in particular to a method and system for manipulating tree structures. Background Technology
[0002] With the development of technology in the field of computer interface design, tree structure display technology has emerged. Tree structure, with its intuitive hierarchical display and parent-child relationship representation, is widely used in user interface design to organize and display data with hierarchical relationships, such as file systems and organizational charts.
[0003] In traditional tree structure processing, the display and manipulation of nodes are usually based on their hierarchical position in the tree. Users can expand or collapse a node's children by clicking the "+" or "-" sign next to it. However, these operations often lead to a re-rendering of the entire tree structure, especially when restoring it after merging nodes. The system often cannot retain the original node expansion information and needs to reload the data.
[0004] However, current tree structure display methods or traditional approaches have some technical problems. Specifically, most tree structures require re-rendering during the restoration operation after merging, and cannot retain the original node expansion information. For example, existing tool libraries such as jQuery-ztree can freely expand nodes, but cannot merge nodes at the same level. Patented technologies such as CN103793135B allow node merging but cannot restore the structure; CN118377473A allows freely expanding nodes but cannot merge nodes at the same level; CN101741708A allows skip-merging of child nodes, but the merged structure cannot be restored, and the child nodes do not have an expanded state; CN102662939B only provides hierarchical display and does not involve merging; CN102841891A only provides sorting functionality and does not support merging. These limitations lead to a decline in user experience and a waste of server resources, because each node expansion requires re-rendering and initiating a server 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 manipulating tree structures, aiming to solve the problems of existing technologies such as the inability to restore the structure in place after merging, the need to re-request data when expanding nodes, and the lack of node caching.
[0006] In a first aspect, a method for manipulating a tree structure, the method comprising:
[0007] Create a unique ID generator to obtain root node data, which includes basic root node information and parent-child relationships of the root node; create a unique ID for the root node using the unique ID generator, and package the unique ID and root node information into a node type; store the root node information, the root node's child node array, and the root node's identifier in a 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 that has not been cached and put it into the node wrapper to output the child node structure; establish the connection relationship between the current node and its child nodes; and call its own renderer through the current node to re-render, wherein the re-rendering only re-renders the current node and its child nodes and updates the expanded state of the current node.
[0009] In response to the user's input of merged nodes, traverse from the root node, put each level of child nodes into 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 more group nodes;
[0010] In response to the user's input to collapse a node, get the current node, update the current node's expanded state to "close", and call its own node renderer to update the user interface;
[0011] In response to the user's input of a non-merge state, the process recursively starts from the root node, extracts its own child nodes from each group node, flattens the child nodes into an array structure, puts them into a node wrapper, and outputs the child node structure; the child nodes are then connected to the current node; and the child nodes are traversed downwards until there are no more child nodes.
[0012] Optionally, in the above scheme, creating a unique ID generator and obtaining root node data includes:
[0013] Using a timestamp and random number-based algorithm as the unique ID generator, the system automatically generates a UUID for each node as a unique ID when a new node is added. At the same time, the system retrieves the node's hierarchical structure from the database, including the node name, description, and subtask list, and encapsulates this information together with the unique ID into a node object, which is stored in a hash table cache in memory.
[0014] Optionally, in the above scheme, responding to the user's expanded node input includes:
[0015] When a user clicks the "+" sign next to a target node, the system retrieves the target node's ID and queries the cached child node information. If the child node is not cached, the system sends a request to the server to retrieve 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 expanded state of the folder node to "expanded".
[0016] Optionally, in the above scheme, the response to the user's merge node input includes:
[0017] After the user selects the "Merge" view option, the system recursively traverses from the root node, uses a group node generator to classify the nodes, and displays them on the user interface as an expandable / collapseable group node; this process is repeated recursively until all nodes have been processed, and finally a merged organizational chart is displayed on the interface.
[0018] Optionally, in the above scheme, the response to the user's collapse node input includes:
[0019] When a user clicks the "-" sign next to a node, the system retrieves the ID of the current node, calls the node renderer, and updates the interface only for that node and its child nodes, hiding the content of the sub-chapter.
[0020] Optionally, in the above scheme, the conversion to a non-merged state includes:
[0021] When the user selects the "Expand" button or option, the system recursively processes the nodes starting from the root node, flattening each group of nodes and placing them into a node wrapper. The system then re-establishes the connection between each child node and its parent node on the user interface and updates the display status of the child nodes. This process is repeated recursively until all child nodes have been expanded, displaying a non-merged node classification tree on the interface.
[0022] Secondly, a system for operating a tree structure, the system comprising:
[0023] Initialization module: Used to create a unique ID generator, obtain root node data, the root node data including root node basic information and root node parent-child relationship; 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 root node's child node array and the root node's identifier in a cache;
[0024] Expand Node Module: Responds to the user's expand node input, obtains the current node ID; queries the cache for the current node ID and filters out the child node information that is not cached; requests the child node information that is not cached and puts it into the node wrapper to output the child node structure; establishes the connection relationship between the current node and its child nodes; and calls its own renderer through the current node to re-render, wherein the re-rendering only re-renders the current node and its child nodes and updates the expand state of the current node;
[0025] Merge Node Module: In response to the user's merge node input, it traverses from the root node, classifies each level of child nodes in the group node generator, and outputs n group nodes; establishes a relationship between the current node and the group nodes; and recursively processes the nodes in each group node until no group node exists.
[0026] Collapse Node Module: Used to respond to the user's input to collapse a node, obtain the current node, update the current node's expanded state to "close", and call its own node renderer to update the user interface;
[0027] The conversion to non-merge module is used to respond to the user's input of the conversion to non-merge status. It recursively starts from the root node, extracts its own child nodes from each group node, flattens the child nodes into an array structure, puts them into a node wrapper, and outputs the child node structure; establishes a connection between the child nodes and the current node; and continues to traverse the child nodes downwards until there are no more child nodes.
[0028] Thirdly, a computer device includes a memory and a processor, the memory storing a computer program, the processor executing the computer program to perform the following steps:
[0029] Create a unique ID generator to obtain root node data, which includes basic root node information and parent-child relationships of the root node; create a unique ID for the root node using the unique ID generator, and package the unique ID and root node information into a node type; store the root node information, the root node's child node array, and the root node's identifier in a cache.
[0030] 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 put it into the node wrapper to output the child node structure; establish the connection relationship between the current node and its child nodes; and call its own renderer through the current node to re-render, wherein the re-rendering only re-renders the current node and its child nodes and updates the expanded state of the current node.
[0031] In response to the user's input of merged nodes, traverse from the root node, put each level of child nodes into 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 more group nodes;
[0032] In response to the user's input to collapse a node, get the current node, update the current node's expanded state to "close", and call its own node renderer to update the user interface;
[0033] In response to the user's input of a non-merge state, the process recursively starts from the root node, extracts its own child nodes from each group node, flattens the child nodes into an array structure, puts them into a node wrapper, and outputs the child node structure; the child nodes are then connected to the current node; and the child nodes are traversed downwards until there are no more child nodes.
[0034] Fourthly, a computer program product includes a computer program / instructions that, when executed by a processor, perform the following steps:
[0035] Create a unique ID generator to obtain root node data, which includes basic root node information and parent-child relationships of the root node; create a unique ID for the root node using the unique ID generator, and package the unique ID and root node information into a node type; store the root node information, the root node's child node array, and the root node's identifier in a cache.
[0036] 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 put it into the node wrapper to output the child node structure; establish the connection relationship between the current node and its child nodes; and call its own renderer through the current node to re-render, wherein the re-rendering only re-renders the current node and its child nodes and updates the expanded state of the current node.
[0037] In response to the user's input of merged nodes, traverse from the root node, put each level of child nodes into 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 more group nodes;
[0038] In response to the user's input to collapse a node, get the current node, update the current node's expanded state to "close", and call its own node renderer to update the user interface;
[0039] In response to the user's input of a non-merge state, the process recursively starts from the root node, extracts its own child nodes from each group node, flattens the child nodes into an array structure, puts them into a node wrapper, and outputs the child node structure; the child nodes are then connected to the current node; and the child nodes are traversed downwards until there are no more child nodes.
[0040] Compared with the prior art, this application has at least the following beneficial effects:
[0041] Based on further analysis and research of existing technologies, this application recognizes that existing technologies suffer from problems such as the inability to restore merged nodes in situ, the need to re-request data when expanding nodes, and the lack of node caching. By creating a unique ID generator, a unique identifier is assigned to each root node and its child nodes. Combined with the root node's basic information and parent-child relationships, this data is encapsulated into node objects and stored in a cached hash table, enabling rapid retrieval and access to node information. When a user expands a node, the system queries and requests uncached child node information from the cache, performing only local rendering updates on the current node and its child nodes, avoiding global re-rendering and improving response speed. Simultaneously, this solution supports user input for merging nodes. A group node generator categorizes child nodes, recursively processing each group node until no group nodes remain, simplifying the view. When a user collapses a node, the system updates the node state and partially updates the interface. For inputs transitioning to a non-merged state, the system recursively expands the child nodes in each group node, flattens them into an array structure, and re-establishes parent-child connections. This method not only overcomes the limitations of existing technologies but also optimizes the dynamic management of the tree structure and the user interaction experience, achieving efficient data processing and rapid view switching. Attached Figure Description
[0042] Figure 1 A flowchart illustrating a method for manipulating a tree structure according to an embodiment of this application;
[0043] Figure 2 This is a schematic flowchart illustrating the method for operating a tree structure according to one embodiment of this application.
[0044] Figure 3 A schematic diagram illustrating the initialization and user-expanded node process provided in one embodiment of this application;
[0045] Figure 4 This is a schematic flowchart illustrating a user merging operation process according to one embodiment of this application.
[0046] Figure 5 A flowchart illustrating a user restore and merge operation provided in one embodiment of this application;
[0047] Figure 6This is one of the schematic diagrams of the operation interface of the method for operating a tree structure provided in one embodiment of this application;
[0048] Figure 7 A second schematic diagram of the operation interface of the method for operating a tree structure provided in one embodiment of this application;
[0049] Figure 8 The third schematic diagram of the operation interface of the method for operating a tree structure provided in one embodiment of this application;
[0050] Figure 9 Fourth schematic diagram of the operation interface of the method for operating a tree structure provided in one embodiment of this application;
[0051] Figure 10 Fifth schematic diagram of the operation interface of the method for operating a tree structure provided in one embodiment of this application;
[0052] Figure 11 A schematic diagram of the user interface for a method of operating a tree structure provided in one embodiment of this application is shown in Figure 6.
[0053] Figure 12 The seventh schematic diagram of the operation interface of the method for operating a tree structure provided in one embodiment of this application;
[0054] Figure 13 This is an internal structural diagram of a computer device in one embodiment. Detailed Implementation
[0055] To make the objectives, technical solutions, and advantages of this application clearer, the following detailed description is provided in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the scope of this application.
[0056] In one embodiment, such as Figure 1 As shown, a method for manipulating a tree structure is provided, including the following steps:
[0057] Create a unique ID generator to obtain root node data, which includes basic root node information and parent-child relationships of the root node; create a unique ID for the root node using the unique ID generator, and package the unique ID and root node information into a node type; store the root node information, the root node's child node array, and the root node's identifier 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 put it into the node wrapper to output the child node structure; establish the connection relationship between the current node and its child nodes; and call its own renderer through the current node to re-render, wherein the re-rendering only re-renders the current node and its child nodes and updates the expanded state of the current node.
[0059] In response to the user's input of merged nodes, traverse from the root node, put each level of child nodes into 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 more group nodes;
[0060] In response to the user's input to collapse a node, get the current node, update the current node's expanded state to "close", and call its own node renderer to update the user interface;
[0061] In response to the user's input of a non-merge state, the process recursively starts from the root node, extracts its own child nodes from each group node, flattens the child nodes into an array structure, puts them into a node wrapper, and outputs the child node structure; the child nodes are then connected to the current node; and the child nodes are traversed downwards until there are no more child nodes.
[0062] In this embodiment, the step of creating a unique ID generator and obtaining root node data includes:
[0063] Using a timestamp and random number-based algorithm as the unique ID generator, the system automatically generates a UUID for each node as a unique ID when a new node is added. At the same time, the system retrieves the node's hierarchical structure from the database, including the node name, description, and subtask list, and encapsulates this information together with the unique ID into a node object, which is stored in a hash table cache in memory.
[0064] In this embodiment, responding to the user's expanded node input includes:
[0065] When a user clicks the "+" sign next to a target node, the system retrieves the target node's ID and queries the cached child node information. If the child node is not cached, the system sends a request to the server to retrieve 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 expanded state of the folder node to "expanded".
[0066] In this embodiment, responding to the user's merge node input includes:
[0067] After the user selects the "Merge" view option, the system recursively traverses from the root node, uses a group node generator to classify the nodes, and displays them on the user interface as an expandable / collapseable group node; this process is repeated recursively until all nodes have been processed, and finally a merged organizational chart is displayed on the interface.
[0068] In this embodiment, the response to user collapse node input includes:
[0069] When a user clicks the "-" sign next to a node, the system retrieves the ID of the current node, calls the node renderer, and updates the interface only for that node and its child nodes, hiding the content of the sub-chapter.
[0070] In this embodiment, the conversion to a non-merged state includes:
[0071] When the user selects the "Expand" button or option, the system recursively processes the nodes starting from the root node, flattening each group of nodes and placing them into a node wrapper. The system then re-establishes the connection between each child node and its parent node on the user interface and updates the display status of the child nodes. This process is repeated recursively until all child nodes have been expanded, displaying a non-merged node classification tree on the interface.
[0072] This embodiment creates a unique ID generator to assign a unique identifier to each root node and its child nodes. Combining the root node's basic information and parent-child relationships, this data is encapsulated into node objects and stored in a cached hash table, enabling rapid retrieval and access to node information. When a user expands a node, the system queries and requests uncached child node information from the cache, performing only local rendering updates on the current node and its child nodes, avoiding global re-rendering and improving response speed. Simultaneously, this solution supports user-merged node input. A group node generator categorizes child nodes, recursively processing each group node until no more group nodes exist, simplifying the view. When a user collapses a node, the system updates the node state and partially updates the interface. For inputs transitioning to a non-merged state, the system recursively expands the child nodes in each group node, flattens them into an array structure, and re-establishes parent-child connections. This method not only overcomes the limitations of existing technologies but also optimizes the dynamic management of the tree structure and the user interaction experience, achieving efficient data processing and rapid view switching.
[0073] In one embodiment, such as Figure 2 As shown, a method for manipulating tree structures is provided, which constructs two tree data structures A and B, and a cache hash table (containing information about the nodes themselves and their parent-child relationships).
[0074] like Figure 3 and Figure 6As shown, a unique ID generator is created to obtain root node data (including the basic information of the current node and the parent-child relationship of the node), a unique ID is created for the root node, the unique ID and the root node information are packaged into a node type, and the root node information, the root node's pns array and the root node's identifier pn are stored in the cache.
[0075] In one embodiment, such as Figure 7 As shown, clicking the "+" button to the right of the root node will immediately expand the node to the right with nine child nodes and display detailed information about these child nodes. The working principle is as follows:
[0076] Get the current node ID, query the cache for that ID and filter out the information of child nodes that are not cached, request the information of the child nodes that are not cached, put them into the node wrapper, and output the child node structure. This step will not repeatedly retrieve cached node information. Establish a connection relationship between the current node and its child nodes. The current node calls its own renderer to re-render. This step only re-renders the current node and its child nodes, and does not perform a global re-render. Update the expanded state of the current node.
[0077] like Figure 4 and Figure 8 As shown, in the non-merging state, a merging operation is performed (from tree structure A to tree structure B). The merging operation is performed for the user. The 9 nodes to the right of the root node of the original graph will be converted into group nodes according to the merging strategy and immediately displayed on the interface. Its working principle is as follows: start traversing from the root node, put the child nodes of each level into the group node generator for classification, output n group nodes, establish a relationship between the current node and the group node, recursively traverse the nodes in each group node until there are no more group nodes.
[0078] Collapsing a node in the merged / non-merged state includes: getting the current node, updating the node's expanded state to "close", calling its own node renderer, and converting the merged state to the non-merged state (restoring in place, changing from structure B to structure A without repeated data fetching).
[0079] In one embodiment, such as Figure 5 , Figure 9 and Figure 10 As shown, when the merging strategy in the upper left corner is switched to the "no merging" state (i.e., merge and restore), the group node will immediately become a normal node, and the expanded child nodes of the group node will still maintain their original expanded state. The working principle is as follows: recursively starting from the root node, each group node extracts its own child nodes, flattens them into an array structure, puts them into a node wrapper, outputs the child node structure, establishes a connection between these child nodes and the current node, and the child nodes continue to traverse downwards until there are no more child nodes.
[0080] like Figure 11 As shown, a graph is provided to display the merged state according to a certain strategy, such as... Figure 12 As shown, when the merged state in the top left corner is changed and restored to the unmerged state, the expanded merged nodes still retain their original expanded state when restored; only the child nodes are changed.
[0081] This embodiment effectively reduces the burden on the server when handling tree structure merging and restoration operations. First, the solution eliminates the need to re-request server data during restoration operations, reducing network communication and server processing requirements. Second, when a merge / restore operation is needed, the solution only re-renders group nodes, not the entire tree structure, improving rendering efficiency and optimizing user experience. Furthermore, for expanded nodes, when they are closed and then expanded again, the solution utilizes cached data, avoiding unnecessary server requests and improving response speed. Finally, for nodes with duplicate information, the solution intelligently identifies and reuses existing data, avoiding redundant data requests and further enhancing performance.
[0082] In one embodiment, a system for manipulating a tree structure is provided, comprising:
[0083] Initialization module: Used to create a unique ID generator, obtain root node data, the root node data including root node basic information and root node parent-child relationship; 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 root node's child node array and the root node's identifier in a cache;
[0084] Expand Node Module: Responds to the user's expand node input, obtains the current node ID; queries the cache for the current node ID and filters out the child node information that is not cached; requests the child node information that is not cached and puts it into the node wrapper to output the child node structure; establishes the connection relationship between the current node and its child nodes; and calls its own renderer through the current node to re-render, wherein the re-rendering only re-renders the current node and its child nodes and updates the expand state of the current node;
[0085] Merge Node Module: In response to the user's merge node input, it traverses from the root node, classifies each level of child nodes in the group node generator, and outputs n group nodes; establishes a relationship between the current node and the group nodes; and recursively processes the nodes in each group node until no group node exists.
[0086] Collapse Node Module: Used to respond to the user's input to collapse a node, obtain the current node, update the current node's expanded state to "close", and call its own node renderer to update the user interface;
[0087] The conversion to non-merge module is used to respond to the user's input of the conversion to non-merge status. It recursively starts from the root node, extracts its own child nodes from each group node, flattens the child nodes into an array structure, puts them into a node wrapper, and outputs the child node structure; establishes a connection between the child nodes and the current node; and continues to traverse the child nodes downwards until there are no more child nodes.
[0088] The specific implementation details of each module can be found in the above description of the methods for manipulating tree structures, and will not be repeated here.
[0089] In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as follows: Figure 13 As shown, the computer device includes a processor, memory, and network interface connected via a system bus. The processor provides computing and control capabilities, and the network interface enables communication with external terminals via a network connection. The computer device implements the aforementioned method of operating a tree structure by loading and running a computer program.
[0090] Those skilled in the art will understand that Figure 13 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device to which the present application is applied. Specific computer devices may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0091] In one embodiment, a computer program product is also provided, including a computer program / instructions that, when executed by a processor, relate to all or part of the processes in the methods of the above embodiments.
[0092] The technical features of the above embodiments can be combined in any way. For the sake of brevity, 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, they should be considered to be within the scope of this specification.
Claims
1. A method of operating a tree structure, characterized by, The method comprises: Creating a unique ID generator, obtaining root node data, the root node data comprising root node basic information and parent-child relationship of the root node; creating a unique ID for the root node by the unique ID generator, wrapping the unique ID and root node information into a node type; storing the root node information, the child node array of the root node and the identifier of the root node into a cache; the creating of the unique ID generator and the obtaining of the root node data comprise: using an algorithm based on a timestamp and a random number as the unique ID generator, and when a new node is added, the system automatically generates a UUID for each node as a unique ID; at the same time, the system obtains the hierarchical structure of the node from the database, including the node name, description and child task list, and encapsulates these information together with the unique ID into a node object and stores it in a hash table cache in the memory; In response to an expand node input of a user, obtaining a current node ID; querying the current node ID in the cache and filtering out the un-cached child node information; requesting the child node information of the un-cached information and putting it into a node wrapper, outputting a child node structure; establishing a connection relationship between the current node and the child node; and calling a renderer of the current node to perform re-rendering, wherein the re-rendering only re-renders the current node and the child node and updates the expansion state of the current node; the response to the expand node input of the user comprises: the user clicking a "+" sign beside a target node, the system obtaining the ID of the target node and querying the child node information in the cache; if the child node is 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 the child nodes on the user interface and updates the expansion state of the folder node to "expanded"; In response to a merge node input of a user, the merging operation in a current non-merging state is converted from a tree structure A to a tree structure B, starting from the root node, each layer of child nodes is put into a group node generator for classification, and n group nodes are output; a relationship between the current node and the group node is established; the nodes in each group node are recursively processed until there is no group node; In response to a fold node input of a user, obtaining a current node, updating the expansion state of the current node to "close", calling a node renderer of the current node to update the user interface, and realizing in-place restoration from the tree structure B to the tree structure A without repeated data pulling; In response to a non-merging state input of a user, starting from the root node, extracting the child nodes of each group node, flattening the child nodes into an array structure, putting the array structure into a node wrapper, and outputting a child node structure; establishing a connection between the child nodes and the current node; and continuing to traverse the child nodes downward until there is no child node; The response to the fold node input of the user comprises: The user clicks a "-" sign beside a node, the system obtains the ID of the current node, calls a node renderer, and only updates the interface of the node and its child nodes, hiding the child chapter content.
2. The method of claim 1, wherein, The response to the merge node input of the user comprises: After the user selects the "merge" view option, the system recursively traverses from the root node, uses the group node generator to classify the nodes, and displays them as an expandable / collapsible group node on the user interface; this process is recursively performed until all nodes are processed, and finally a merged organizational structure diagram is displayed on the interface.
3. The method of claim 1, wherein, The response to the user's non-merge state includes: After the user selects the "expand" button or option, the system recursively processes from the root node, 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 node; this process is recursively performed until all child nodes are expanded, and a non-merge state node classification tree is displayed on the interface.
4. A system for operating a tree structure, characterized by The system includes: The initialization module is used to create a unique ID generator, obtain root node data, and the root node data includes root node basic information and the parent-child relationship of the root node; the unique ID generator is used to create a unique ID for the root node, and the unique ID and root node information are wrapped as a node type; the root node information and the identifier of the root node are stored in the cache; the unique ID generator obtains root node data, including using a timestamp-based and random number-based algorithm as a unique ID generator, when a new node is added, the system automatically generates a UUID for each node as a unique ID; at the same time, the system obtains the hierarchical structure of the node from the database, including the node name, description, and child task list, and encapsulates these information together with the unique ID into a node object, which is stored in the hash table cache in memory; The expand node module is 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 unbuffered child node information, request the child node information that is not buffered, and place it in the node wrapper to output the child node structure; the connection relationship between the current node and the child node is established; and the current node calls its own renderer for re-rendering, which only re-renders the current node and the child node, and updates the expansion state of the current node; the response to the user's expand node input includes: the user clicks the "+" next to the target node, the system obtains the ID of the target node, queries the child node information in the cache; if the child node is not buffered, the system sends a request to the server to obtain the child node data and update 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"; The merge node module is used to respond to the user's merge node input, and the merge operation in the current non-merge state is converted from tree structure A to tree structure B, starting from the root node, each layer of child nodes is placed in the group node generator for classification, and n group nodes are output; the current node is related to the group node; recursively process the nodes in each group node until there are no group nodes. The closing node module is used to acquire the current node and update the current node expansion state to "close" in response to the user's closing node input, call the node renderer of the self to update the user interface, realize the in-place restoration, convert from the tree structure B to the tree structure A, and not perform repeated data pulling; The non-conversion merging module is used to extract the self child node from each group node and lay the self child node as an array structure in the node wrapper and output the child node structure in response to the user's non-conversion merging state input, establish a connection between the child node and the current node, and continue to traverse the child node downward until there is no child node. 5.A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the computer device is configured to perform the method according to any one of claims 1-4 when the computer program is executed by the processor. The processor executes the computer program to implement the steps of the method in any one of claims 1 to 3.
6. A computer program product comprising computer programs / instructions, characterized in that, The computer program / instruction is executed by the processor to implement the steps of the method in any one of claims 1 to 3.
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