coolite有关 Treepanel 节点问题


        /// 当选中子节点时父节点也选中
        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);
           }
        }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值