Use JavaScript to implement new discovery and transfer of checkbox on Treeview

Source: Internet
Author: User
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");

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.