Recently use the TreeView control to implement permissions management and allocation, have encountered many problems. The questions that use the TreeView control need to be solved:
Control Cascade Checkbox selection, synchronization
Number Click to expand the subordinate node
Problem One Solution You can complete the TreeView.htc file:
In TreeView.htc, find DocheckboxClick (), which adds the processing method for setting up other node status, as follows:
//
// docheckboxclick ()
//
Function DocheckboxClick (EL)
{
El.checked =! El.checked;
Var evt = creteEventObject ();
Evt.treenodeIndex = GetNodeIndex (EL);
g_nodeclicked = EL;
TvevtCheck.fire (evt);
Settreenodestate (EL);
}
Function SetTreenodestate (EL)
{
Var State = private_getattribute (EL, "Checked");
// Set the child node selection
_SETCHILDNODE (EL, STATE);
// Set the parent node
_SETPARENTNODE (EL, STATE);
}
/ / Set the child node status
Function_SetChildNode (EL, State)
{
Var childnodes = el.children.tags ("treenode");
IF (ChildNodes.Length> 0)
{// if Has Childs
For (var i = 0; i <= childnodes.length-1; i )
{
CNODE = CHILDNODES [I];
Private_setttribute (ChildNodes [i], "checked", state);
_SAVECHECKSTATE (ChildNodes [i]);
_SETCHILDNODE (ChildNodes [i], state);
}
}
}
Function_SetParentNode (EL, State)
{
Var parentnode = el.parentelement;
IF (ParentNode! = Null && Private_getattribute (ParentNode, "Tagname") == "Treenode")
{
IF (! _ ChecksiblingDNode (EL))
{
Private_setttribute (ParentNode, "Checked", State;
_SAVECHECKSTATE (PARENTNODE);
_SETPARENTNODE (Parentnode, State);
}
}
}
Function _ChecksiblingDNode (EL)
{
Var parentnode = el.parentelement;
Var SiblingNodes = ParentNode.Children.tags ("Treenode");
For (var i = 0; i <= siblingNodes.length-1; i )
{
Var cnode = siblingNodes [i];
IF (EL! = cnode)
{
IF (private_getattribute (cnode, "checked"))
{
Return True;
}
}
}
Return False;
}
Function _savecheckstate (EL)
{
IF (GetNodeIndex (EL))
QueueEvent ('Oncheck', GetNodeIndex (EL));
}
// docheckboxclick ()
//
Function DocheckboxClick (EL)
{
El.checked =! El.checked;
Var evt = creteEventObject ();
Evt.treenodeIndex = GetNodeIndex (EL);
g_nodeclicked = EL;
TvevtCheck.fire (evt);
Settreenodestate (EL);
}
Function SetTreenodestate (EL)
{
Var State = private_getattribute (EL, "Checked");
// Set the child node selection
_SETCHILDNODE (EL, STATE);
// Set the parent node
_SETPARENTNODE (EL, STATE);
}
/ / Set the child node status
Function_SetChildNode (EL, State)
{
Var childnodes = el.children.tags ("treenode");
IF (ChildNodes.Length> 0)
{// if Has Childs
For (var i = 0; i <= childnodes.length-1; i )
{
CNODE = CHILDNODES [I];
Private_setttribute (ChildNodes [i], "checked", state);
_SAVECHECKSTATE (ChildNodes [i]);
_SETCHILDNODE (ChildNodes [i], state);
}
}
}
Function_SetParentNode (EL, State)
{
Var parentnode = el.parentelement;
IF (ParentNode! = Null && Private_getattribute (ParentNode, "Tagname") == "Treenode")
{
IF (! _ ChecksiblingDNode (EL))
{
Private_setttribute (ParentNode, "Checked", State;
_SAVECHECKSTATE (PARENTNODE);
_SETPARENTNODE (Parentnode, State);
}
}
}
Function _ChecksiblingDNode (EL)
{
Var parentnode = el.parentelement;
Var SiblingNodes = ParentNode.Children.tags ("Treenode");
For (var i = 0; i <= siblingNodes.length-1; i )
{
Var cnode = siblingNodes [i];
IF (EL! = cnode)
{
IF (private_getattribute (cnode, "checked"))
{
Return True;
}
}
}
Return False;
}
Function _savecheckstate (EL)
{
IF (GetNodeIndex (EL))
QueueEvent ('Oncheck', GetNodeIndex (EL));