How to add two different arrays under the ztree parent directory under an asynchronous request?

there is such a requirement: as shown in the following figure. Considering the large amount of data, the back end gives two interfaces. The first interface: to enter the page is to return all the root directories (an array, implemented), which is a request. The second interface: click the current directory to pass the current id, to the background to request to get the subordinate directory and the blue font part. At this time, two arrays will be returned. One array contains all the subdirectories under the current click directory, and the other array contains the contents of blue fonts. In order to facilitate me, I asked the backend to add a pid, to the two arrays returned by this API that is the same as the currently clicked directory. Ask the god, how can the second request add two different arrays to the current directory to achieve the effect of the following figure? (you can also copy by clicking on the blue font section).

May.08,2021

you can use the onNodeCreated callback to capture the rendered events of each node. At this time, you can operate dom on your own


actually solve this problem simply: use the datasFilter, of asynchronous request and the addDiyDom method of adding dom. Here, I would like to thank the author of ztree for developing such a perfect plug-in.

Menu