Jquery zTree tree control asynchronous loading operation_jquery
zTree uses the core code of JQuery to implement a set of Tree plug-ins that can complete most common functions
- Compatible with IE, FireFox, Chrome and other browsers
- Multiple Tree instances can be generated simultaneously in one page
- Support JSON data
- Supports one-time static generation and Ajax asynchronous loading in two ways
- Supports multiple event responses and feedback
- Supports tree node movement, editing, and deletion
- Supports any skin change/personalized icon (relying on css)
- Supports extremely flexible checkbox or radio selection function
- Simple parameter configuration to achieve flexible functions
Asynchronous loading means: when you click to expand the tree node, request the background action to return the child node data of the clicked node and load it.
Here we mainly design the async attribute setting of ztree’s setting variable:
var setting = { async: { enable: true, url:InitServiceIpsData.action, autoParam:[id, name], dataFilter: filter },
When you click to expand the tree node, the action specified by the URL will be requested to obtain the child node data, and then bound to the ztree.
Note that the background action here returns a JSON string, and ztree only receives arrays when binding new node data, so you need to use the filter function to perform data cleaning and conversion operations before binding, and convert the string into an array:
//过滤异步加载ztree时返回的数据 function filter(treeId, parentNode, childNodes) { if (!childNodes) return null; childNodes = eval((+childNodes+)); //必须转换为[{id:103,pId:1,name:'子节点3'}];这样的格式 return childNodes; }
When you click to expand the ztree tree node, the action will be requested to obtain the child node data and bound.
The following is an implementation of background action:
public String InitServiceIpsData() { HttpServletRequest request = ServletActionContext.getRequest(); String id = request.getParameter(id); String name = request.getParameter(name); System.out.println(请求获取+name+的ip列表); List<hashmap<string,object>> list = new ArrayList<hashmap<string,object>>(); for(int i = 1; i <= 2; i++){ HashMap<string,object> hm = new HashMap<string,object>(); hm.put(id, id + 0 + i); hm.put(pId, id); hm.put(name, name + _IP_ + i); hm.put(isParent, false); list.add(hm); } JSONArray finalJson = JSONArray.fromObject(list); this.initServiceIpsData = finalJson.toString(); return SUCCESS; }</string,object></string,object></hashmap<string,object></hashmap<string,object>
The above are the detailed steps for implementing asynchronous loading operation of Jquery zTree tree control. I hope it will be helpful to everyone's learning.

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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

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

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

Although HTML itself cannot read files, file reading can be achieved through the following methods: using JavaScript (XMLHttpRequest, fetch()); using server-side languages (PHP, Node.js); using third-party libraries (jQuery.get() , axios, fs-extra).

Delegation is a type-safe reference type used to pass method pointers between objects to solve asynchronous programming and event handling problems: Asynchronous programming: Delegation allows methods to be executed in different threads or processes, improving application responsiveness. Event handling: Delegates simplify event handling, allowing events such as clicks or mouse movements to be created and handled.

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

目录1:basename()2:copy()3:dirname()4:disk_free_space()5:disk_total_space()6:file_exists()7:file_get_contents()8:file_put_contents()9:filesize()10:filetype()11:glob()12:is_dir()13:is_writable()14:mkdir()15:move_uploaded_file()16:parse_ini_file()17:

jQuery is a popular JavaScript library widely used in web development. During web development, it is often necessary to dynamically add new rows to tables through JavaScript. This article will introduce how to use jQuery to add new rows to a table, and provide specific code examples. First, we need to introduce the jQuery library into the HTML page. The jQuery library can be introduced in the tag through the following code:

How to prevent page redirection in WordPress? In website development, sometimes we want to implement a page non-jump setting in WordPress, that is, during certain operations, the page content can be updated without refreshing the entire page. This improves user experience and makes the website smoother. Next, we will share how to implement the page non-jump setting in WordPress and provide specific code examples. First, we can use Ajax to prevent the page from jumping. Ajax
