transfer treeview checkbox

 

ContractedBlock.gif ExpandedBlockStart.gif
None.gif<script>
None.gif
None.gif            
function getNodeFromNodes(objNodes)
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif{
InBlock.gif                
var objID=objNodes.getAttribute("ID");
InBlock.gif                objID
=objID.substring(0,objID.indexOf("Nodes"))+"CheckBox";
InBlock.gif                
var objNode=document.getElementById(objID);
InBlock.gif                
return objNode;
ExpandedBlockEnd.gif            }

None.gif            
function getNodesFromNode(objNode)
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif{
InBlock.gif                
var objID=objNode.getAttribute("ID");
InBlock.gif                objID
=objID.substring(0,objID.indexOf("CheckBox"))+"Nodes";
InBlock.gif                
var objNodes=document.getElementById(objID);
InBlock.gif                
return objNodes;
ExpandedBlockEnd.gif            }

None.gif
None.gif            
function getParentByTagName(element, tagName)
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif{
InBlock.gif                
var parent = element.parentNode;
InBlock.gif                
var upperTagName = tagName.toUpperCase();
InBlock.gif                
while (parent && (parent.tagName.toUpperCase() != upperTagName))
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    parent 
= parent.parentNode ? parent.parentNode : parent.parentElement;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
return parent;
ExpandedBlockEnd.gif            }

None.gif
None.gif            
function getChildCheckState(parentNode,type)
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif{
InBlock.gif                
var parentNodes
InBlock.gif                
if(type==0)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    parentNodes
=getNodesFromNode(parentNode)
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    parentNodes
=parentNode
ExpandedSubBlockEnd.gif                }

InBlock.gif                
if(parentNodes==null || parentNodes == "undefined")
InBlock.gif                    
return true;
InBlock.gif                
for(var i=0; i<parentNodes.children.length; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
var childNode = parentNodes.children[i];
InBlock.gif                    
if(childNode.tagName=="INPUT" && childNode.type=="checkbox")                    
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
if(childNode.checked==false)
InBlock.gif                            
return false;
ExpandedSubBlockEnd.gif                    }

InBlock.gif                    
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                    
dot.gif{
InBlock.gif                        
var returnState=getChildCheckState(childNode,1);
InBlock.gif                        
if(returnState==false)
InBlock.gif                            
return false;
ExpandedSubBlockEnd.gif                    }

ExpandedSubBlockEnd.gif                }

InBlock.gif                
return true;                
ExpandedBlockEnd.gif            }

None.gif
None.gif            
function checkParent(parentNode)
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif{
InBlock.gif                
if(getChildCheckState(parentNode,0)==true)
InBlock.gif                    parentNode.checked
=true
InBlock.gif                
else
InBlock.gif                    
return;
InBlock.gif                
var objParentNodes = getParentByTagName(parentNode,"div");                
InBlock.gif                
if(objParentNodes==null || objParentNodes == "undefined")
InBlock.gif                    
return;
InBlock.gif                
var objParentNode=getNodeFromNodes(objParentNodes);
InBlock.gif                
if(objParentNode==null || objParentNode == "undefined")
InBlock.gif                    
return;
InBlock.gif                
if(objParentNode.tagName!="INPUT" && objParentNode.type == "checkbox")
InBlock.gif                    
return;
InBlock.gif                checkParent(objParentNode);
ExpandedBlockEnd.gif            }

None.gif
None.gif            
function setParentNodeState(childNode,checkState)
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif{
InBlock.gif                
var objParentNodes = getParentByTagName(childNode,"div");
InBlock.gif                
if(objParentNodes==null || objParentNodes == "undefined")
InBlock.gif                    
return;
InBlock.gif                
var objParentNode = getNodeFromNodes(objParentNodes);
InBlock.gif                
if(objParentNode==null || objParentNode == "undefined")
InBlock.gif                    
return;
InBlock.gif                
if(objParentNode.tagName!="INPUT" && objParentNode.type == "checkbox")
InBlock.gif                    
return;
InBlock.gif                
if(checkState==true)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    checkParent(objParentNode)
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    objParentNode.checked 
= false;
InBlock.gif                    setParentNodeState(objParentNode,
false);
ExpandedSubBlockEnd.gif                }
           
ExpandedBlockEnd.gif            }

None.gif            
function setChildNodeState(parentNodes,checkState)
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif{
InBlock.gif                
for(var i=0; i<parentNodes.children.length; i++)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    
var childNode = parentNodes.children[i];
InBlock.gif                    
if(childNode.tagName=="INPUT" && childNode.type=="checkbox")                    
InBlock.gif                        childNode.checked 
= checkState;                          
InBlock.gif                    setChildNodeState(childNode, checkState);
ExpandedSubBlockEnd.gif                }
                    
ExpandedBlockEnd.gif            }

None.gif            
function TransferCheck()
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif{     
InBlock.gif
InBlock.gif                
var objNode = event.srcElement; 
InBlock.gif                
if(objNode==null || objNode=="undefined")
InBlock.gif                    
return;
InBlock.gif                
if(objNode.tagName!="INPUT" || objNode.type!="checkbox")
InBlock.gif                    
return;
InBlock.gif                               
InBlock.gif                
var objNodes = getNodesFromNode(objNode);
InBlock.gif                
if(objNodes==null || objNodes == "undefined")
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    setParentNodeState(objNode,objNode.checked);
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    setChildNodeState(objNodes,objNode.checked);
InBlock.gif                    setParentNodeState(objNode,objNode.checked);
ExpandedSubBlockEnd.gif                }

InBlock.gif
ExpandedBlockEnd.gif            }

None.gif
None.gif    
</script>  

转载于:https://www.cnblogs.com/jiemupig/archive/2006/05/10/396014.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值