The sub-nodes can only be set to the same state as the parent node when the parent node is selected or not selected.
Sometimes, when selecting a child knot, we want its parent node to be selected at the same time. The following Javascript Code This function can be implemented:
// For Treeview controller, where pagetv is a Treeview object
Function tree_oncheck ()
{
VaR node = pagetv. gettreenode (event. treenodeindex );
VaR pchecked = node. getattribute ("checked ");
If (pchecked = true)
{
Setfathercheck (node); // This function implements the above additional functions
}
Setcheck (node, pchecked );
Pagetv. queueevent ('oncheck', node. getnodeindex ());
}
Function setcheck (node, PC)
{
VaR childnode = new array ();
Childnode = node. getchildren ();
If (parseint (childnode. Length )! = 0)
{
For (VAR I = 0; I <childnode. length; I ++)
{
VaR cNode = childnode [I];
If (cNode. getattribute ("checked ")! = Pc)
{
If (parseint (cNode. getchildren (). Length )! = 0)
Setcheck (cNode, PC );
CNode. setattribute ("checked", PC );
Pagetv. queueevent ('oncheck', cNode. getnodeindex ());
}
}
}
}
function setfathercheck (node)
{< br> var fathernode;
fathernode = node. getparent ();
If (fathernode! = NULL)
{< br> If (fathernode. getattribute ("checked ")! = True)
{< br> setfathercheck (fathernode);
fathernode. setattribute ("checked", true);
pagetv. queueevent ('oncheck', fathernode. getnodeindex ();
}< BR >}
you need to modify a bug in the Microsoft Treeview control.
you need to modify Inetpub \ wwwroot \ webctrl_client \ defaults 0 \ Treeview. HTC.
set function docheckboxclick (EL) to the first line.
El. Checked =! El. Checked;
changed to:
El. Checked =! El. getattribute ("checked");