/// 当选中子节点时父节点也选中
function checkParent(node) {
var ischeck = node.attributes["checked"]
if (ischeck == true) {
var parent = node.parentNode;
if (parent != null) {
parent.attributes["checked"] = ischeck;
if (parent.getUI().checkbox != null) {
parent.getUI().checkbox.checked = ischeck;
}
checkParent(parent);
}
}
}
/// 当取消一个节点的选中状态时,则些节点的父节点也取消选选中
function uncheckParent(node) {
var ischeck = node.attributes["checked"]
if (ischeck == false ) {
var parent = node.parentNode;
if (parent != null) {
parent.attributes["checked"] = false ;
if (parent.getUI().checkbox != null) {
parent.getUI().checkbox.checked = false ;
}
uncheckParent(parent);
}
}
}
///当选中一个节点时,则些节点以下的所有子节点全部选中,反选则子节点全部反选
function fathercheck(item) {
var chNode;
for (var i = 0; i < item.childNodes.length; i++) {
chNode = item.childNodes[i];
chNode.attributes.checked = item.attributes.checked;
if (chNode.getUI().checkbox != null) {
chNode.getUI().checkbox.checked = item.attributes.checked;
}
fathercheck(chNode);
}
}