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,所以有很多不了解,但通过周六日努力,还是做出来了.现在 ...
随机推荐
- 导入excel表格的数据--->到mysql中
01下载excel类,将Classes文件夹放入ThinkPHP\Extend\Vendor\位置 下载地址 http://phpexcel.codeplex.com/releases/view/26 ...
- Visual Studio 2010 安装帮助文档问题
今天重装系统,装完VS2010后,如往常一样安装文档,却弹出如下错误"Could not create the local store in the specified folder.... ...
- 使 httpClient 支持中文
一个有效的方法:重载 PostMethod 的 getRequestCharSet 方法 1: class PostChinese { 2: HttpClient httpClient = new H ...
- python--tile函数
1.函数的定义与说明 tile函数位于python模块 numpy.lib.shape_base中,功能是重复某个数组.比如tile(A,n),功能是将数组A重复n次,构成一个新的数组. 2.函数操作 ...
- 网页 HTML表格
今天,我开始学习了网站开发中HTML的部分内容,主要包括标签和表格. body的属性:bgcolor,background,text,topmargin,bottomargin,leftmargin, ...
- window.showModalDialog()的简单用法
//创建一个显示html内容的模态对话框: vReturnValue = window.showModalDialog(sURL [, vArguments] [,sFeatures]) //创建一个 ...
- 常用的meta标签
<!-- 关键字,搜所引擎 SEO --> <meta http-equiv="keywords" content="关键字1,关键字2,...&quo ...
- 安装gensim
安装了一天的gensim,其中因为版本不一致等等各种问题纠结了好久,现记录如下: 正确安装方式: 1. 安装python2.7 2. 下载Python Extension Packages对应版本的n ...
- 局部内部类访问方法的参数和局部变量必须是final的
内部类的种类一共分为四种,我看其他几种内部类的时候思路都是很清晰的,然后我就碰到了这一条:"方法中的内部类可以访问外部类成员.对于方法的参数和局部变量,必须有final修饰才可以访问&quo ...
- 【第一篇】Python基础
Python学习 学习站点:https://www.shiyanlou.com/ 1 hello world code如下: $ python [15:50:40] Python2.7.6(defau ...