在初始加载树形控件的时候调用zTree的expandNode (node, expandFlag, sonSign, focus, callbackFlag)方法
node:树形节点
expandFlag:是否展开节点
sonSign:是否展开其子孙节点
focus:展开或折叠节点后是否设置焦点
callbackFlag:这行该方法是否触发回调函数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
|
var
zNodes =
""
;
var
setting = {
check: {
enable:
true
},
data: {
//数据加载
keep: {
parent:
true
,
leaf:
true
},
simpleData: {
enable:
true
,
idKey:
"Id"
,
pIdKey:
"Pid"
,
},
key: {
name:
"Name"
}
}
};
function
Inint() {
//初始化加载节点
$.ajax({
global:
true
,
async:
false
,
cache:
false
,
dataType:
"json"
,
url:
'../Ajax/test.ashx'
,
type:
"post"
,
//data: { "roleId": GetQueryString("roleId") },
success:
function
(data) {
zNodes = data;
}
});
};
$(
function
() {
Inint();
//加载数据
$.fn.zTree.init($(
"#zTree"
), setting, zNodes);
var
treeObj = $.fn.zTree.getZTreeObj(
"checkerTree"
);
var
nodes = treeObj.getNodes();
for
(
var
i = 0; i < nodes.length; i++) {
//设置节点展开
treeObj.expandNode(nodes[i],
true
,
false
,
true
);
}
});
|