ext 树状结构中父子节点的管理选择
//添加监听 设置树的节点选择的级联关系
var listenerCheck = function(node, checked) {
childHasChecked(node,checked);
var parentNode = node.parentNode;
if(parentNode != null) {
parentCheck(parentNode,checked);
}
};
//级联选中父节点
var parentCheck = function(node ,checked){
var childNodes = node.childNodes;
for (var i = 0; i < childNodes.length; i++) {
if (childNodes[i].get('checked')) {
node.set('checked',checked);
continue;
}else{
node.set('checked',false);
break;
}
};
var parentNode = node.parentNode;
if (parentNode != null ) {
parentCheck(parentNode,checked);
}
}
//级联选择子节点
var childHasChecked = function (node, checked) {
node.cascadeBy(function (child) {
child.set("checked",checked)
});
}
var listenerCheck = function(node, checked) {
childHasChecked(node,checked);
var parentNode = node.parentNode;
if(parentNode != null) {
parentCheck(parentNode,checked);
}
};
//级联选中父节点
var parentCheck = function(node ,checked){
var childNodes = node.childNodes;
for (var i = 0; i < childNodes.length; i++) {
if (childNodes[i].get('checked')) {
node.set('checked',checked);
continue;
}else{
node.set('checked',false);
break;
}
};
var parentNode = node.parentNode;
if (parentNode != null ) {
parentCheck(parentNode,checked);
}
}
//级联选择子节点
var childHasChecked = function (node, checked) {
node.cascadeBy(function (child) {
child.set("checked",checked)
});
}