Home > Web Front-end > JS Tutorial > extjs discussion on the issue of selecting all treePanel chekBox and clearing the selection_extjs

extjs discussion on the issue of selecting all treePanel chekBox and clearing the selection_extjs

WBOY
Release: 2016-05-16 17:38:23
Original
1201 people have browsed it
Copy code The code is as follows:

//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;
}
}
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template