1
<
iewc:TreeView
id
="TreeView1"
style
="Z-INDEX: 101; LEFT: 320px; POSITION: absolute; TOP: 160px"
2
runat
="server"
>
3
<
iewc:TreeNode
Text
="Node0"
>
4
<
iewc:TreeNode
Text
="Node3"
>
5
<
iewc:TreeNode
Text
="Node9"
>
6
<
iewc:TreeNode
Text
="Node0"
></
iewc:TreeNode
>
7
<
iewc:TreeNode
Text
="Node1"
></
iewc:TreeNode
>
8
</
iewc:TreeNode
>
9
<
iewc:TreeNode
Text
="Node10"
>
10
<
iewc:TreeNode
Text
="Node2"
></
iewc:TreeNode
>
11
<
iewc:TreeNode
Text
="Node3"
></
iewc:TreeNode
>
12
</
iewc:TreeNode
>
13
</
iewc:TreeNode
>
14
<
iewc:TreeNode
Text
="Node4"
></
iewc:TreeNode
>
15
</
iewc:TreeNode
>
16
<
iewc:TreeNode
Text
="Node1"
>
17
<
iewc:TreeNode
Text
="Node5"
>
18
<
iewc:TreeNode
Text
="Node11"
>
19
<
iewc:TreeNode
Text
="Node4"
></
iewc:TreeNode
>
20
<
iewc:TreeNode
Text
="Node5"
></
iewc:TreeNode
>
21
</
iewc:TreeNode
>
22
<
iewc:TreeNode
Text
="Node12"
></
iewc:TreeNode
>
23
</
iewc:TreeNode
>
24
<
iewc:TreeNode
Text
="Node6"
></
iewc:TreeNode
>
25
</
iewc:TreeNode
>
26
<
iewc:TreeNode
Text
="Node2"
>
27
<
iewc:TreeNode
Text
="Node7"
>
28
<
iewc:TreeNode
Text
="Node13"
>
29
<
iewc:TreeNode
Text
="Node6"
></
iewc:TreeNode
>
30
<
iewc:TreeNode
Text
="Node7"
></
iewc:TreeNode
>
31
</
iewc:TreeNode
>
32
<
iewc:TreeNode
Text
="Node14"
></
iewc:TreeNode
>
33
</
iewc:TreeNode
>
34
<
iewc:TreeNode
Text
="Node8"
></
iewc:TreeNode
>
35
</
iewc:TreeNode
>
36
</
iewc:TreeView
>
![None.gif](/Images/OutliningIndicators/None.gif)
2
![None.gif](/Images/OutliningIndicators/None.gif)
3
![None.gif](/Images/OutliningIndicators/None.gif)
4
![None.gif](/Images/OutliningIndicators/None.gif)
5
![None.gif](/Images/OutliningIndicators/None.gif)
6
![None.gif](/Images/OutliningIndicators/None.gif)
7
![None.gif](/Images/OutliningIndicators/None.gif)
8
![None.gif](/Images/OutliningIndicators/None.gif)
9
![None.gif](/Images/OutliningIndicators/None.gif)
10
![None.gif](/Images/OutliningIndicators/None.gif)
11
![None.gif](/Images/OutliningIndicators/None.gif)
12
![None.gif](/Images/OutliningIndicators/None.gif)
13
![None.gif](/Images/OutliningIndicators/None.gif)
14
![None.gif](/Images/OutliningIndicators/None.gif)
15
![None.gif](/Images/OutliningIndicators/None.gif)
16
![None.gif](/Images/OutliningIndicators/None.gif)
17
![None.gif](/Images/OutliningIndicators/None.gif)
18
![None.gif](/Images/OutliningIndicators/None.gif)
19
![None.gif](/Images/OutliningIndicators/None.gif)
20
![None.gif](/Images/OutliningIndicators/None.gif)
21
![None.gif](/Images/OutliningIndicators/None.gif)
22
![None.gif](/Images/OutliningIndicators/None.gif)
23
![None.gif](/Images/OutliningIndicators/None.gif)
24
![None.gif](/Images/OutliningIndicators/None.gif)
25
![None.gif](/Images/OutliningIndicators/None.gif)
26
![None.gif](/Images/OutliningIndicators/None.gif)
27
![None.gif](/Images/OutliningIndicators/None.gif)
28
![None.gif](/Images/OutliningIndicators/None.gif)
29
![None.gif](/Images/OutliningIndicators/None.gif)
30
![None.gif](/Images/OutliningIndicators/None.gif)
31
![None.gif](/Images/OutliningIndicators/None.gif)
32
![None.gif](/Images/OutliningIndicators/None.gif)
33
![None.gif](/Images/OutliningIndicators/None.gif)
34
![None.gif](/Images/OutliningIndicators/None.gif)
35
![None.gif](/Images/OutliningIndicators/None.gif)
36
![None.gif](/Images/OutliningIndicators/None.gif)
别忘了在窗体的onload事件中调用 ExpandOneTwo()函数
![None.gif](/Images/OutliningIndicators/None.gif)
![None.gif](/Images/OutliningIndicators/None.gif)
第1种非递归的方法:
1
function
ExpandOneTwo()
2
{
3
4
var
NodeArray
=
new
Array();
5
NodeArray
=
TreeView1.getChildren();
6
for
(i
=
0
;i
<
NodeArray.length;i
++
)
7
{
8
cNode
=
NodeArray[i];
9
cNode.setAttribute(
"
expanded
"
,
"
true
"
);
10
//
alert(cNode.getAttribute("Text"));
11
var
cNodeArray
=
new
Array();
12
cNodeArray
=
cNode.getChildren();
13
for
(j
=
0
;j
<
cNodeArray.length;j
++
)
14
{
15
var
ccNode
=
cNodeArray[j];
16
ccNode.setAttribute(
"
expanded
"
,
"
true
"
);
17
}
18
}
19
}
20
![None.gif](/Images/OutliningIndicators/None.gif)
2
![None.gif](/Images/OutliningIndicators/None.gif)
3
![None.gif](/Images/OutliningIndicators/None.gif)
4
![None.gif](/Images/OutliningIndicators/None.gif)
5
![None.gif](/Images/OutliningIndicators/None.gif)
6
![None.gif](/Images/OutliningIndicators/None.gif)
7
![None.gif](/Images/OutliningIndicators/None.gif)
8
![None.gif](/Images/OutliningIndicators/None.gif)
9
![None.gif](/Images/OutliningIndicators/None.gif)
10
![None.gif](/Images/OutliningIndicators/None.gif)
11
![None.gif](/Images/OutliningIndicators/None.gif)
12
![None.gif](/Images/OutliningIndicators/None.gif)
13
![None.gif](/Images/OutliningIndicators/None.gif)
14
![None.gif](/Images/OutliningIndicators/None.gif)
15
![None.gif](/Images/OutliningIndicators/None.gif)
16
![None.gif](/Images/OutliningIndicators/None.gif)
17
![None.gif](/Images/OutliningIndicators/None.gif)
18
![None.gif](/Images/OutliningIndicators/None.gif)
19
![None.gif](/Images/OutliningIndicators/None.gif)
20
![None.gif](/Images/OutliningIndicators/None.gif)
第2种递归的方法:
1
<
script language
=
"
javascript
"
>
2
3
function
ExpandOneTwo()
4
{
5
//
alert(arguments[0]);
6
7
var
c
=
arguments[
0
];
8
var
NodeArray
=
new
Array();
9
if
(c
==
null
)
10
{
11
NodeArray
=
TreeView1.getChildren();
12
13
if
(NodeArray
!=
null
)
14
for
(
var
i
=
0
;i
<
NodeArray.length;i
++
)
15
{
16
cNode
=
NodeArray[i];
17
cNode.setAttribute(
"
expanded
"
,
"
true
"
);
18
if
((cNode.getParent()
!=
null
)
&&
(cNode.getParent().getParent()
==
null
))
19
return
;
20
ExpandOneTwo(cNode);
21
}
22
}
23
else
24
{
25
26
NodeArray
=
c.getChildren();
27
if
(NodeArray
!=
null
)
28
for
(
var
i
=
0
;i
<
NodeArray.length;i
++
)
29
{
30
cNode
=
NodeArray[i];
31
cNode.setAttribute(
"
expanded
"
,
"
true
"
);
32
if
((cNode.getParent()
!=
null
)
&&
(cNode.getParent().getParent()
==
null
))
33
return
;
34
ExpandOneTwo(cNode);
35
}
36
}
37
38
39
}
40
</
script
>
![None.gif](/Images/OutliningIndicators/None.gif)
2
![None.gif](/Images/OutliningIndicators/None.gif)
3
![None.gif](/Images/OutliningIndicators/None.gif)
4
![None.gif](/Images/OutliningIndicators/None.gif)
5
![None.gif](/Images/OutliningIndicators/None.gif)
6
![None.gif](/Images/OutliningIndicators/None.gif)
7
![None.gif](/Images/OutliningIndicators/None.gif)
8
![None.gif](/Images/OutliningIndicators/None.gif)
9
![None.gif](/Images/OutliningIndicators/None.gif)
10
![None.gif](/Images/OutliningIndicators/None.gif)
11
![None.gif](/Images/OutliningIndicators/None.gif)
12
![None.gif](/Images/OutliningIndicators/None.gif)
13
![None.gif](/Images/OutliningIndicators/None.gif)
14
![None.gif](/Images/OutliningIndicators/None.gif)
15
![None.gif](/Images/OutliningIndicators/None.gif)
16
![None.gif](/Images/OutliningIndicators/None.gif)
17
![None.gif](/Images/OutliningIndicators/None.gif)
18
![None.gif](/Images/OutliningIndicators/None.gif)
19
![None.gif](/Images/OutliningIndicators/None.gif)
20
![None.gif](/Images/OutliningIndicators/None.gif)
21
![None.gif](/Images/OutliningIndicators/None.gif)
22
![None.gif](/Images/OutliningIndicators/None.gif)
23
![None.gif](/Images/OutliningIndicators/None.gif)
24
![None.gif](/Images/OutliningIndicators/None.gif)
25
![None.gif](/Images/OutliningIndicators/None.gif)
26
![None.gif](/Images/OutliningIndicators/None.gif)
27
![None.gif](/Images/OutliningIndicators/None.gif)
28
![None.gif](/Images/OutliningIndicators/None.gif)
29
![None.gif](/Images/OutliningIndicators/None.gif)
30
![None.gif](/Images/OutliningIndicators/None.gif)
31
![None.gif](/Images/OutliningIndicators/None.gif)
32
![None.gif](/Images/OutliningIndicators/None.gif)
33
![None.gif](/Images/OutliningIndicators/None.gif)
34
![None.gif](/Images/OutliningIndicators/None.gif)
35
![None.gif](/Images/OutliningIndicators/None.gif)
36
![None.gif](/Images/OutliningIndicators/None.gif)
37
![None.gif](/Images/OutliningIndicators/None.gif)
38
![None.gif](/Images/OutliningIndicators/None.gif)
39
![None.gif](/Images/OutliningIndicators/None.gif)
40
![None.gif](/Images/OutliningIndicators/None.gif)