Home > Web Front-end > JS Tutorial > JS control ASP.NET's treeview control selects all or cancels (sample code)_javascript skills

JS control ASP.NET's treeview control selects all or cancels (sample code)_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:08:57
Original
1208 people have browsed it

Copy code The code is as follows:

2. Add yourTreeView.Attribute.Add("OnCheck","CheckNode(yourTreeView.getTreeNode(yourTreeView.clickedNodeIndex))") in the Page_load() event of *.aspx.cs
*/

//Recursively traverse all child nodes
function CheckNode(currentNode)
{
var childNode=new Array();
var parentNodeChild=new Array();
var isChecked;
childNode=currentNode.getChildren();
if(currentNode.getAttribute('checked'))
{
isChecked=true;
}
else
{
isChecked=false;
}
//Parent node processing
if(currentNode.getParent()!=null)
{
//Selected processing
if(currentNode.getAttribute ('Checked'))
{
ParentNode(currentNode);
}
else
//Uncheck
{
ChildNode(currentNode);
}
}
else
{
//Do nothing
}
//Child node processing
if(childNode.length>0)
{
for(var i=0;i {
childNode.setAttribute("Checked",isChecked);
if(childNode.getChildren().length>0)
{
CheckNode(childNode);
}
}
}

}
//Recursively select the parent node
function ParentNode(currentNode)
{
if(currentNode.getParent()!=null)
{
currentNode.getParent().setAttribute('Checked',true);
//Recursively call ParentNode(currentNode) to traverse updates The parent node of the previous layer
ParentNode(currentNode.getParent());
}
}
//Recursively unselect the parent node
function ChildNode(currentNode)
{
if(currentNode.getParent()!=null)
{ var checkedCount=0;
var childNode=currentNode.getParent().getChildren();
for (var i=0; i {
if(childNode.getAttribute('Checked'))
{
checkedCount ;
}
}
if(checkedCount= =0)
{
currentNode.getParent().setAttribute('Checked',false);
}
//Recursively call ChildNode(currentNode) to traverse the higher-level parent node
ChildNode (currentNode.getParent()); The problem




Copy code


The code is as follows:

 var   AllRootNode=new   Array();  
    AllRootNode=TreeView1.getChildren();  
    AlertNode(AllRootNode);        

    function   AlertNode(NodeArray)  
    {  
      if(parseInt(NodeArray.length)==0)  
        return;  
      else  
      {  
        for(i=0;i        {  
          var   cNode;  
          cNode=NodeArray;  
          alert(cNode.getAttribute("Text"));  
          if(parseInt(cNode.getChildren().length)!=0)  
            AlertNode(cNode.getChildren());          
        }  
      }  
    } 

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template