


zTree is a multi-functional "tree plug-in" implemented with jQuery. Excellent performance, flexible configuration, and combination of multiple functions are the biggest advantages of zTree.
zTree Features Editing
● zTree v3.0 divides the core code according to functions, and unnecessary code does not need to be loaded
● Adopting lazy loading technology, tens of thousands of nodes can be easily loaded, and it can basically achieve instant killing even under IE6
● Compatible with IE, FireFox, Chrome, Opera, Safari and other browsers
● Support JSON data
● Supports static and Ajax asynchronous loading of node data
● Supports any skin change/custom icon (relying on css)
● Supports extremely flexible checkbox or radio selection function
● Provides multiple event response callbacks
● Flexible editing (add/delete/modify/check) functions, you can drag and drop nodes at will, and you can drag and drop multiple nodes
● Multiple Tree instances can be generated simultaneously in one page
● Simple parameter configuration to achieve flexible functions
Advantages of zTree Editing
The author of zTree uses his spare time to continuously improve zTree functions, and can also communicate with users in a timely manner and respond to various questions in a timely manner, so that new users can quickly master it. Currently, more and more users are using zTree to replace the original tree plug-in in the system, including the recently released latest version of the QUI framework.
Related plug-in version:
jquery.ztree.exedit-3.4.js
jquery.ztree.all-3.4.js
jquery-1.8.0.js
function onAsyncSuccess(event, treeId, treeNode, msg) { curAsyncCount--; if (curStatus == "expand") { expandNodes(treeNode.children); } else if (curStatus == "async") { asyncNodes(treeNode.children); } if (curAsyncCount <= ) { curStatus = ""; // 节点定位 if(devicesSelect.selectNodeId){ // 节点变成被选中状态 var zTree = $.fn.zTree.getZTreeObj(zTreeId); zTree.cancelSelectedNode(); $("#" + devicesSelect.selectNodeId + "_a").addClass("curSelectedNode"); $("#treeDiv").animate({scrollTop:$("#"+devicesSelect.selectNodeId).offset().top-},);//是ms,也可以用slow代替 devicesSelect.selectNodeId = ""; } } } function expandNodes(nodes) { if (!nodes) return; curStatus = "expand"; var zTree = $.fn.zTree.getZTreeObj(zTreeId); for (var i=, l=nodes.length; i<l; i++) { if(ids.indexOf(nodes[i].id) != -){ if (nodes[i].isParent&&(ids.substring(,ids.indexOf(","))!=nodes[i].id)) { if(nodes[i].typeName.indexOf("虚拟")=="-"){ zTree.expandNode(nodes[i], true, false, false); } else if(nodes[i].type.indexOf(type)>"-"){ zTree.expandNode(nodes[i], true, false, false); } } else { goAsync = true; } } } if(goAsync==true){ var id_ = ids.substring(,ids.indexOf(",")); var node = zTree.getNodeByParam("id",id_); goAsync = false; me.curStatus = ""; me.type = ""; me.selectNodeId = node.tId; } }
Positioning ideas:
1. Suppose you want to locate node A. The unique identifier of node A is objid
2. Get all superior objids from db based on objid, splice them together and save them in the ids variable.
3. Call expandNodes in the onAsyncSuccess method. In this method, pass [if (nodes[i].isParent&&(ids.substring(0,ids.indexOf(","))!=nodes[i].id) )] filter and expand the nodes with id in ids.
4. Under normal circumstances, at the end of expansion, obtain the node A object through [var node = zTree.getNodeByParam("id",id_);] based on objid, and then select it through [zTree.selectNode(node);] node.
In this case, the target node can be located and selected. However, when there is a lot of data with the same parent node as the node, node A may not appear in the visible area. Searching the source code, I found that Ztree uses the [$("#" node.tId).focus().blur();] method to achieve positioning. But unfortunately, there is a BUG.
So, use the scroll bar to control the positioning yourself. The implementation is as follows:
1. Delete [zTree.selectNode(node);] to prevent positioning conflicts
2. In the onAsyncSuccess method, determine when the node is expanded, obtain the offset of node A, and assign the value to the scrollTop attribute of the DIV where the tree is located.
$("#treeDiv1").animate({scrollTop:$("#" devicesSelect.selectNodeId).offset().top-300},1000);//1000 is ms, you can also use slow instead
Note: devicesSelect.selectNodeId is the node tid of node A, obtained through [me.selectNodeId = node.tId]; the id attribute of the div where the treeDiv1 tree is located
3. Cancel the previously selected node: zTree.cancelSelectedNode();
4. Add the selected status class to node A: $("#" devicesSelect.selectNodeId "_a").addClass("curSelectedNode");
The author said lightly: For the second point, I originally wanted to use [$("#treeDiv1").scrollTop($("#" devicesSelect.selectNodeId).offset().top-200);] , although it is effective, when there are too many nodes on the same layer, it still cannot enter the visible area. I deeply suspect that it is because the tree has not been expanded at this time, so I used animation, which is a rogue move.
The author’s last words: If there are any errors in this article, please point it out. I will be very grateful. . . .
The above content is the entire description of how to solve the bug that occurs when ztree cannot enter the visible area when acquiring selected nodes. I hope you like it.

JavaScript core data types are consistent in browsers and Node.js, but are handled differently from the extra types. 1) The global object is window in the browser and global in Node.js. 2) Node.js' unique Buffer object, used to process binary data. 3) There are also differences in performance and time processing, and the code needs to be adjusted according to the environment.

JavaScriptusestwotypesofcomments:single-line(//)andmulti-line(//).1)Use//forquicknotesorsingle-lineexplanations.2)Use//forlongerexplanationsorcommentingoutblocksofcode.Commentsshouldexplainthe'why',notthe'what',andbeplacedabovetherelevantcodeforclari

The main difference between Python and JavaScript is the type system and application scenarios. 1. Python uses dynamic types, suitable for scientific computing and data analysis. 2. JavaScript adopts weak types and is widely used in front-end and full-stack development. The two have their own advantages in asynchronous programming and performance optimization, and should be decided according to project requirements when choosing.

Whether to choose Python or JavaScript depends on the project type: 1) Choose Python for data science and automation tasks; 2) Choose JavaScript for front-end and full-stack development. Python is favored for its powerful library in data processing and automation, while JavaScript is indispensable for its advantages in web interaction and full-stack development.

Python and JavaScript each have their own advantages, and the choice depends on project needs and personal preferences. 1. Python is easy to learn, with concise syntax, suitable for data science and back-end development, but has a slow execution speed. 2. JavaScript is everywhere in front-end development and has strong asynchronous programming capabilities. Node.js makes it suitable for full-stack development, but the syntax may be complex and error-prone.

JavaScriptisnotbuiltonCorC ;it'saninterpretedlanguagethatrunsonenginesoftenwritteninC .1)JavaScriptwasdesignedasalightweight,interpretedlanguageforwebbrowsers.2)EnginesevolvedfromsimpleinterpreterstoJITcompilers,typicallyinC ,improvingperformance.

JavaScript can be used for front-end and back-end development. The front-end enhances the user experience through DOM operations, and the back-end handles server tasks through Node.js. 1. Front-end example: Change the content of the web page text. 2. Backend example: Create a Node.js server.

Choosing Python or JavaScript should be based on career development, learning curve and ecosystem: 1) Career development: Python is suitable for data science and back-end development, while JavaScript is suitable for front-end and full-stack development. 2) Learning curve: Python syntax is concise and suitable for beginners; JavaScript syntax is flexible. 3) Ecosystem: Python has rich scientific computing libraries, and JavaScript has a powerful front-end framework.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1
Easy-to-use and free code editor

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.
