原创

[coolite] TreePanel CheckBox联动

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://david.blog.csdn.net/article/details/6126125

function treepanelcheck(item) {

    treepanelchildcheck(item);
treepanelparentcheck(item);
}
function treepanelchildcheck(item) {
   
var chNode;

   
if (item.childNodes.length > 0) {
       
if (item.attributes.checked == true) {
           
for (var i = 0; i < item.childNodes.length; i++) {
                chNode
= item.childNodes[i];
                chNode.attributes.checked
= true;
                chNode.getUI().checkbox.checked
= true;


            }
        }
       
if (item.attributes.checked == false) {
           
for (var i = 0; i < item.childNodes.length; i++) {
                chNode
= item.childNodes[i];
                chNode.attributes.checked
= false;
                chNode.getUI().checkbox.checked
= false;

            }
        }
    }
}
function treepanelparentcheck(item) {
   
var chNode;
   
var checkBool;
   
if (item.parentNode.parentNode != null) {
       
if (item.attributes.checked == false) {

           
for (var i = 0; i < item.parentNode.childNodes.length; i++) {

                chNode
= item.parentNode.childNodes[i];
               
if (chNode.attributes.checked == true) {
                    checkBool
= true;
                   
break;
                }

               
//chNode.attributes.checked = true;

            }
           
if (checkBool == true) {
                item.parentNode.attributes.checked
= true;
                item.parentNode.getUI().checkbox.checked
= true;
            }
           
else {
                item.parentNode.attributes.checked
= false;
                item.parentNode.getUI().checkbox.checked
= false;
            }
        }
       
if (item.attributes.checked == true) {
            item.parentNode.attributes.checked
= true;
           
if (item.parentNode.getUI().checkbox != null) {
                item.parentNode.getUI().checkbox.checked
= item.attributes.checked;
            }
        }
    }
}

 

<Listeners>                                   
                                     
                                       
<CheckChange Handler="treepanelcheck(node)" />                                                              
                                    </Listeners>  

文章最后发布于: 2011-01-10 09:16:00
展开阅读全文
0 个人打赏
私信求帮助

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 鲸 设计师: meimeiellie

分享到微信朋友圈

×

扫一扫,手机浏览