zTree异步加载并初始化树时全部展开(贴主要代码)
<%@page pageEncoding="UTF-8"%> <%@include file="/commons/include/html_doctype.html"%> <html> <head> <title>法律库选择</title> <script type="text/javascript" src="${ctx}/js/tree/jquery.ztree.js"></script> <script type="text/javascript">
var accuseTree = null; $(function() { load_accuse_tree(); expandAll(); });//罪名类型 function load_accuse_tree(){ var setting = { data: { key : { name: "typeName" }, simpleData: { enable: true, idKey: "typeId", pIdKey: "upId" } }, async: { enable: true, url:"${ctx}/dss/system/accuseType/getTreeData.ht", autoParam:["typeId"] }, callback:{ onAsyncSuccess: zTreeOnAsyncSuccess } }; accuseTree=$.fn.zTree.init($("#SEARCH_BY_ACCUSETYPE"), setting,treeNodes); }; , asyncForAll = false,goAsync = false; function beforeAsync() { curAsyncCount++; } function zTreeOnAsyncSuccess(event, treeId, treeNode, msg) { curAsyncCount--; if (curStatus == "expand") { expandNodes(treeNode.children); } else if (curStatus == "async") { asyncNodes(treeNode.children); } if (curAsyncCount <= 0) { if (curStatus != "init" && curStatus != "") { asyncForAll = true; } curStatus = ""; } } function expandAll() { if (!check()) { return; } var zTree = $.fn.zTree.getZTreeObj("SEARCH_BY_ACCUSETYPE"); if (asyncForAll) { zTree.expandAll(true); } else { expandNodes(zTree.getNodes()); if (!goAsync) { curStatus = ""; } } } function check() { if (curAsyncCount > 0) { return false; } return true; } function expandNodes(nodes) { if (!nodes) return; curStatus = "expand"; var zTree = $.fn.zTree.getZTreeObj("SEARCH_BY_ACCUSETYPE"); for (var i=0, l=nodes.length; i<l; i++) { zTree.expandNode(nodes[i], true, false, false); if (nodes[i].isParent && nodes[i].zAsync) { expandNodes(nodes[i].children); } else { goAsync = true; } } } function asyncNodes(nodes) { if (!nodes) return; curStatus = "async"; var zTree = $.fn.zTree.getZTreeObj("SEARCH_BY_ACCUSETYPE"); for (var i=0, l=nodes.length; i<l; i++) { if (nodes[i].isParent && nodes[i].zAsync) { asyncNodes(nodes[i].children); } else { goAsync = true; zTree.reAsyncChildNodes(nodes[i], "refresh", true); } } }
</script> </head> <body> <div id="SEARCH_BY_ACCUSETYPE"></div> </body> </html>
ztree中加上红色区域即可实现异步加载展开全部节点
zTree异步加载并初始化树时全部展开(贴主要代码)的更多相关文章
- ztree异步加载
Ztree异步加载的意思就是: 当点击展开树节点时,才去请求后台action返回点击节点的子节点数据并加载. 直接贴代码(SpringMvc+Mybatis): 前台页面ztreeList.jsp: ...
- jquery zTree异步加载的例子
下面是使用zTree异步加载的一个例子: 1)初始化树的时候是ajax请求,返回nodes列表来初始化树的:如果一开始就异步的话,$.fn.zTree.init($("#zTree" ...
- zTree 异步加载
zTree异步加载数据的简单实现,更为详细的Api请参考 zTree官网 http://www.treejs.cn/ <link href="~/Content/ztree/css ...
- ztree异步加载树节点
参考文档:https://www.cnblogs.com/tenWood/p/8620708.html ztree api地址:http://www.treejs.cn/v3/api.php 说明:j ...
- Jquery Ztree异步加载树
1. 下载jquery的JS文件/ztree的CSS文件和JS文件 https://jquery.com/download/ https://gitee.com/zTree/zTree_v3/tree ...
- Jquery树控件ZTree异步加载
异步加载的意思就是: 当点击展开树节点时,才去请求后台action返回点击节点的子节点数据并加载. 这里面主要设计ztree的setting变量的async属性设置: var setting = { ...
- Ztree异步加载自动展开节点
在Ztree的官网Demo中,有自动展开的例子,是通过设置节点属性open:true来实现自动展开的,但是在异步加载中,这个属性设置为true也不会自动展开,因为open:true是指在有子节点的情况 ...
- 关于ztree异步加载的问题(二)
本来以为这个异步加载会很难控制,因为考虑到ztree节点图标的控制,结果并不是那么困难,ztree自己控制图标,你只要在json中设置isParent:true,它自己会识别父节点并控制图标,以下是核 ...
- ztree异步加载---------补发周日内容
上周六老师要求和大三的进行JAVA知识交流,总体来说就是给大三学长做的东西打分,然后大三学长再教我们如果构建ztree.毕竟第一次接触ztree,所以有很多不了解,但通过周六日努力,还是做出来了.现在 ...
随机推荐
- HTML通过事件传递参数到js一
原文链接:http://bbs.51cto.com/thread-1098421-1-1.html 目标处理函数为selectAttr(test) 1.直接传递给定参数如: onclick=" ...
- jQuery技巧大放送【转】
1.关于页面元素的引用 通过jquery的$()引用元素包括通过id.class.元素名以及元素的层级关系及dom或者xpath条件等方法,且返回的对象为jquery对象(集合对象),不能直接调用do ...
- Java JVM 内存泄漏--全解析和处理办法 [ 转载 ]
Java JVM 内存泄露——全解析和处理办法 [转载] @author 小筐子 @address http://www.jianshu.com/p/bf159a9c391a JA ...
- 2016弱校联盟十一专场10.2——Around the World
题目链接:Around the World 题意: 给你n个点,有n-1条边,现在这n-1条边又多增加了ci*2-1条边,问你有多少条欧拉回路 题解: 套用best定理 Best Theorem:有向 ...
- 重装系统之后Hexo快速配置
安装准备软件 Node.js Git 打开 Git Bash hexo文件夹,右键: 配置SSH Keys 检查SSH keys设置,看一下电脑现有的ssh key cd ~/. ssh 检查本机的s ...
- php 积少成多!
- java实现UDP聊天---转载
import java.io.*; import java.net.*; class Send implements Runnable { private DatagramSocket ds; pub ...
- hadoop namespace
As underscore(_) is not allowed. It may be the problem if your other configuration are ok. Your conf ...
- C++中##(两个井号)和#(一个井号)用法
C(和C++)中的宏(Macro)属于编译器预处理的范畴,属于编译期概念(而非运行期概念).下面对常遇到的宏的使用问题做了简单总结.关 于#和##在C语言的宏中,#的功能是将其后面的宏参数进行字符串化 ...
- IOS 第三方库之-MBProgressHUD的使用详解
转自作者: weidfyr http://www.aiuxian.com/article/p-3121607.html 1,MBProgressHUD常用属性和用法Demo - (void)test ...