Jquery ztree asynchronous search (search for leaves) practice, jqueryztree

Source: Internet
Author: User

Jquery ztree asynchronous search (search for leaves) practice, jqueryztree

I. Initial asynchronous loading tree

A root node is provided by default during initialization, and the first layer is manually triggered by asynchronous loading,

The Code is as follows:

Var treeSetting = {async: {enable: true, <a href = "http://my.oschina.net/wealpan/admin/" xxx/demo. do? Method = listByTree "rel =" nofollow "> url:" xxx/demo. do? Method = listByTree </a> ", dataType:" json ", autoParam: [" id = pid "]}, view: {dblClickExpand: true, selectedMulti: false, expandSpeed: ($. browser. msie & parseInt ($. browser. version) <= 6 )? "": "Fast"}, data: {simpleData: {enable: true, idKey: "id", pIdKey: "pid", rootPId: "root" }}, callback: {onNodeCreated: zTreeOnNodeCreated}; // Default root Node var rootNode = {"id": 0, "pid": "root", "name": "item category ", "open": true, "isParent": true}; $ (document ). ready (function () {var zTreeObj = $. fn. zTree. init ($ ("# tree"), treeSetting, rootNode); var node = zTreeObj. getNodeByParam ("id", 0, null); zTreeObj. reAsyncChildNodes (node, "refresh ");});

Ii. asynchronous searching of leaf nodes

Asynchronous fuzzy search of leaf nodes may be used when JQuery ZTREE is used,

 

If zTreeObj. expandNode is used only to expand and modify nodes, asynchronous loading cannot be triggered. In this case, you must manually call the asynchronous loading method for processing. The solution is as follows:
Search parameters are taken to the background by setting values in the otherParam array (otherParam must be set to an empty array if no parameters exist; otherwise, the previous parameter will always be taken to the background ); manually asynchronously load the callback function onNodeCreated after the node is created.

The Code is as follows:

Function searchM () {var param = $. trim ($ ("input [name = 'param']"). val (); var treeObj = $. fn. zTree. getZTreeObj ("tree"); var node = treeObj. getNodeByParam ("id", 0, null); if (param! = "") {Param = encodeURI (param); treeObj. setting. async. otherParam = ["param", param];} when the else {// search parameter is null, the parameter array must be set to null treeObj. setting. async. otherParam = [];} treeObj. reAsyncChildNodes (node, "refresh");} function zTreeOnNodeCreated (event, treeId, treeNode) {var param <span> </span> = $. tr <span> </span> im ($ ("input [name = 'param']"). val (); var treeObj = $. fn. zTree. getZTreeObj ("tree ");// If (param! = "" & TreeNode. isParent) {treeObj. reAsyncChildNodes (treeNode, "refresh ");}};

The above is all about jquery ztree asynchronous search. I hope it will be helpful for your learning.

Articles you may be interested in:
  • Jquery zTree asynchronous loading simple instance sharing
  • How to combine jquery dialog with ztree
  • Jquery ztree uses json data in the drop-down tree.
  • Summary of common functions and features of the infinite tree Jquery plug-in zTree
  • Getting started with Jquery tree plug-in zTree
  • Introduction to JQuery ztree asynchronous loading instance
  • Jquery ztree for tree search

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.