About the ExtJS treepanel check box select the parent node and the child node _extjs

Source: Internet
Author: User

ExtJS as shown, implement a tree with a check box, select all child nodes when the parent node is selected. The root node can be canceled when all child nodes are canceled.
Copy Code code as follows:

var fpanel = new Ext.tree.TreePanel ({
ID: ' Ptree ',
Region: ' West ',
Layout: ' Anchor ',
Border:false,
Rootvisible:false,
Root:new Ext.tree.AsyncTreeNode ({}),
listeners:{
"Checkchange": Function (node, state) {
if (Node.parentnode!= null) {
Child node selected
Node.cascade (function (node) {
node.attributes.checked = State;
node.ui.checkbox.checked = State;
return true;
});
Parent node selected
var pnode = Node.parentnode;
if (state | | fpanel.getchecked (ID, pnode) = = "") {
PNode.ui.toggleCheck (state);
pNode.attributes.checked = State;
}
}
}
}
});
Authoritytree (Fpanel);
var authoritytree = function (Fpanel) {
Ext.Ajax.request ({
URL: ' Authoritytree.ashx ',
Method: ' Get ',
Success:function (Request) {
var data = Ext.util.JSON.decode (Request.responsetext);
Fpanel.getrootnode (). appendchild (data);
Fpanel.getrootnode (). Expandchildnodes (True);
Fpanel.expandall ();
},
Failure:function () {
Fpanel.render ();
Ext.MessageBox.show ({
Title: ' Hint ',
Msg: ' Server busy, please use Firefox browser or try again later! ',
Buttons:Ext.MessageBox.OK,
Icon:Ext.MessageBox.ERROR
});
}
});
}

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.