zoukankan      html  css  js  c++  java
  • Ext.net TreePanel获取设置状态

    xxx.SetChecked,xxx.GetChecked如果有不存在的id会出错,可以使用下面方法

    1、写入

    function SetChecked(treepanel, arrayids) {
        var rootnode = treepanel.getRootNode();
        if(rootnode.checkbox!=undefined)
        {
            if (arrayids.contain(rootnode.id))
                rootnode.getUI().checkbox.checked = true;
            else
                rootnode.getUI().checkbox.checked = false;
        }
        findchildnode1(rootnode, arrayids);
    }
    function findchildnode1(node, arrayids) {
        var childnodes = node.childNodes;
        for (var i = 0; i < childnodes.length; i++) {  //从节点中取出子节点依次遍历
            var rootnode = childnodes[i];
            if (rootnode.childNodes.length > 0) {  //判断子节点下是否存在子节点
                findchildnode1(rootnode, arrayids);    //如果存在子节点  递归
            }
            console.log(rootnode.id);
            if (arrayids.contain(rootnode.id))
                rootnode.getUI().checkbox.checked = true;
            else
                rootnode.getUI().checkbox.checked = false;
        }
    }
    Array.prototype.contain = function (val) {
        for (var i = 0; i < this.length; i++) {
            if (this[i] == val) {
                return true;
            }
        }
        return false;
    };

    2、读取,读取选中的节点id和名称

    var rootNode=treePanel.getRootNode();
    if(rootNode!=undefined)
        {
            var ChildNodes=rootNode.childNodes;
            for (var i=0;i<ChildNodes.length;i++)
                {
                    if(ChildNodes[i].getUI().checkbox.checked)
                        {
                            //选中的节点
                        }
                }
        } 
  • 相关阅读:
    tetrahedron (公式)
    Subway (树中心 + 树hash)
    包装类的Null值
    基本数据类型的范围边界
    基本数据类型的装箱和拆箱()优先使用基本数据类型
    第三章-python基础 笔记
    第二章-Python起步
    第一章-欢迎来到python世界
    第八章-连接与多张表的操作
    php错误和异常的处理方式
  • 原文地址:https://www.cnblogs.com/zhaogaojian/p/13723286.html
Copyright © 2011-2022 走看看