zoukankan      html  css  js  c++  java
  • coolite TreePanel CheckBox联动

    代码
    <Listeners>

    <CheckChange Handler="treepanelcheck(node)" />
    </Listeners>
    代码
    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;
    }
    }
    }
    }

  • 相关阅读:
    More Effective C++: 02操作符
    More Effective C++: 01基础议题
    GCD学习(七) dispatch_apply
    GCD学习(六) dispatch_async 和dispatch_sync
    GCD学习(五) dispatch_barrier_async
    GCD 学习(四) dispatch_group
    关于 block的一些浅识
    异常日志记录 DDLog
    Effective Objective-C [下]
    Effective Objective-C [上]
  • 原文地址:https://www.cnblogs.com/hanli/p/1755796.html
Copyright © 2011-2022 走看看