//tree
var treePanel = new Ext.tree.TreePanel ({
id:'ptree',
region:'west',
layout:'anchor',
border:false,
rootVisible: false,
root:{} ,
listeners:{
render: function() {
authorityTree(treePanel); /*render tree*/
},
checkchange: function(node, state) {
if (node.parentNode != null) {
//Select the child node to select the corresponding parent node
var pNode = node.parentNode;
if (state || treePanel.getChecked(id, pNode) == "") {
pNode.ui.toggleCheck(state); // Trigger the parent node to be selected
pNode.attributes.checked = state;
}
}
treeId = node .attributes.id;
treeName = node.attributes.text;
}
}
});
//Action button
tbar: [{
id: ' btnQingKong',
text: 'clear',
iconCls: 'winupdate-icon',
handler: function() {
var nodes = Ext.getCmp('ptree').getChecked() ;
if (nodes && nodes.length) {
for (var i = 0; i < nodes.length; i ) {
//Set the UI status to unselected
nodes[ i].getUI().toggleCheck(false);
//Set node attributes to unchecked state
nodes[i].attributes.checked = false;
}
}
}
},{
id: 'btnQuanXuan',
text: 'Select all',
iconCls: 'winupdate-icon',
handler: function() {
var nodeT = Ext.getCmp('ptree').getRootNode();
treeCheckTrue(nodeT);
}
}]
/**
*checkTree select all
*/
var treeCheckTrue = function( node)
{
node.eachChild(function (child) {
child.getUI().toggleCheck(true);
child.attributes.checked = true;
treeCheckTrue(child) ;
});
}
/**
*checkTree clear
*/
var treeCheckfalse = function(tree)
{
var nodes = tree.getChecked();
if(nodes && nodes.length){
for(var i=0;i//Set the UI status to unselected
nodes[i].getUI ().toggleCheck(false);
//Set node attributes to unchecked state
nodes[i].attributes.checked=false;
}
}
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn