extjs As shown in the figure, implement a tree with check boxes. When the parent node is selected, all child nodes are selected. The root node can only be canceled when all child nodes are canceled.
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: 'Prompt',
msg: 'The server is busy, please use Firefox to browse Browse with your browser or try again later! ',
buttons: Ext.MessageBox.OK,
icon: Ext.MessageBox.ERROR
});
}
});
}
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