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