asp.net1.1下权限配置系统从设计到实现(四)

继续上次的吧,本来还有点瞌睡:) (昨晚的德国VS哥队够精彩),还是坚持写完吧.今天说哈 怎么实现Select All  TreeView全部节点的功能?怎么实现展开和折叠自如?
请看:
节点全部选中的实现:
function  SelectAllFunctions()
        {          
            
var  tree =  document.getElementById(' <%= tvRoleFunctions.ClientID %> ');
            
var  chckAll = document.getElementById(' <%= chSelectAll.ClientID %> ');
            
var  NodeArray = tree.getChildren();        
            
for ( var  i = 0 ;i < NodeArray.length;i ++ )
            {
                    cNode
= NodeArray[i];
                    
if (chckAll.checked )
                    {
                         cNode.setAttribute('checked',
true );
                         GetSelectedFunctionID(cNode);
                         Checked(cNode);                             
                    }
                    
else
                    {
                     cNode.setAttribute('checked',
false );
                     UnChecked(cNode);
                     }
            }
                    
        }    
function  Checked(node)
        {
                
var  NodeArray = node.getChildren();
                
for ( var  i = 0 ;i < NodeArray.length;i ++ )
                {
                     childNode
= NodeArray[i];
                     childNode.setAttribute('checked',
true );
                }
        }
function  UnChecked(node)
        {
                
var  NodeArray = node.getChildren();
                
for ( var  i = 0 ;i < NodeArray.length;i ++ )
                {
                     cNode
= NodeArray[i];
                     cNode.setAttribute('checked',
false );
                }
            
        }
节点的展开和折叠实现:
// TreeView的节点展开收回
function  ExpandAllNodes()
{
   
var  tree = document.getElementById(' <%= tvRoleFunctions.ClientID %> ');
   Expandedall(tree);
}

function  CollospaeAllNodes()
{
 
var  tree = document.getElementById(' <%= tvRoleFunctions.ClientID %> ');
 Unexpandedall(tree);
}
function  Expandedall(node)
{
        
var  i  =   0 ;
        
var  nodes  =   new  Array();
        nodes 
=  node.getChildren();
        
// alert(nodes.length);
         for (i  =   0 ; i  <  nodes.length; i ++ )
        {
            
var  cNode;
            cNode
= nodes[i];
            cNode.setAttribute(
" expanded " " true " );
            
if (parseInt(cNode.getChildren().length)  !=   0  )
            {
                Expandedall(cNode);
            }
        }
}
function  Unexpandedall(node)
{
        
var  i  =   0 ;
        
var  nodes  =   new  Array();
        nodes 
=  node.getChildren();
        
for (i  =   0 ; i  <  nodes.length; i ++ )
        {
            
var  cNode;
            cNode
= nodes[i];
            
if (parseInt(cNode.getChildren().length)  !=   0  )
            {
                Unexpandedall(cNode);
            }
            cNode.setAttribute(
" expanded " " false " );
        }
}
这个怎么调用就不用说了吧!呵呵........
下次写作预告:
在Firefox下TreeView的父子节点联动实现、节点的全部选择和节点的展开和折叠实现.....
http://jigee.cnblogs.com/archive/2006/06/10/422255.html

你可能感兴趣的:(asp.net1.1下权限配置系统从设计到实现(四))