Function groupvisible (){
VaR rootid = iInformation. finditem ("0 ");
VaR A = iInformation. getnextitem (rootid, 11); // you can specify the ID of the subitem.
VaR boolvisible = iInformation. getgroupvisibility (a); // The returned value of subitem visibility
If (boolvisible = 1 ){
// If all the preceding values are visible, they are hidden. At the same time, the button value is visible.
IInformation. setgroupvisibility (iInformation. finditem ("0"), false );
Specified parameter Doc ument. getelementbyid ("btn3"). value = "visible ";
}
Else {
IInformation. setgroupvisibility (iInformation. finditem ("0"), true );
Specified parameter Doc ument. getelementbyid ("btn3"). value = "hidden ";
}
}
// The method for traversing the information tree.
Function informationvist (){
VaR groupid = iInformation. getnextitem (0, 11 );
If (groupid = 0)
{
Alert ("no object in the information tree! ");
Return 0;
}
Else
Informationall (groupid );
}
Function informationall (groupid)
{
VaR A, B, C;
If (groupid = 0) // this judgment is redundant. The previous judgment and
Return 0;
Else {
B = confirm (iInformation. getitemname (groupid) + "_ ID:" + groupid );
// If it is canceled, no information tree traversal is performed.
If (B = false)
{
Return 0;
}
A = groupid;
// Traverse the subnode ID
Groupid = iInformation. getnextitem (groupid, 11); // subnode
// If a subnode exists, this method is nested. If no subnode exists, the same-level node is searched.
If (groupid = 0 ){
Groupid = iInformation. getnextitem (A, 13); // next node of the same level
// Execute nesting when a peer node exists. Not sometimes looking for a parent node
If (groupid = 0 ){
Groupid = iInformation. getnextitem (A, 15); // parent node
C = groupid;
Groupid = iInformation. getnextitem (C, 13 );
// If the same-level node of the parent node exists, the node is nested and does not exist, the parent node of the parent node is searched.
While (groupid = 0 ){
Groupid = iInformation. getnextitem (C, 15 );
Groupid = iInformation. getnextitem (groupid, 13 );
If (groupid = 0)
Return 0;
} // Exit the WHILE LOOP
} // Exit if judgment
} // Exit if judgment
Informationall (groupid );
}
}
By writing this method, we know that the nested method needs to be nested all the time when the conditions are met, and the rest of the work is to find all the branches that do not meet the conditions. In addition, if the branch does not meet the condition, you need to check whether the adjacent branches meet the condition. If the adjacent branches do not meet the condition, you need to find the parent level, if the parent level does not meet the condition, find the parent level at the same level. If the parent level at the same level does not meet the condition, find the parent level at the parent level, if the adjacent branches of the parent class are not satisfied, the loop and judgment will exit. In other cases, nesting is used.