zoukankan      html  css  js  c++  java
  • Ext 遍历树的所有节点

    /**
      * 调用的地方
      */
    
    var rootNode = btn.ownerCt.ownerCt.getRootNode();
    // var rootNode = Ext.getCmp('deptmentTee').getRootNode();
    var nodeList = traverseTree(rootNode);
    
    /**
     * Ext 遍历 tree 的所有节点
     * @param node
     * @returns {}
     */
    function traverseTree(node){
    	var n = {};
    	n.id = node.id;
    	n.name = node.text;
    	n.parentid = node.attributes.parentid;
    	n.isleaf = (node.hasChildNodes()?0:1);
    	n.type = node.attributes.type;
    	
    	if(node.isLeaf()){
    		
    	} else {
    		var cds = node.childNodes;
    		var arr = [];
    		for (var i=0; i<cds.length; i++) {
    			arr.push(traverseTree(cds[i]));
    		}
    		n.children = arr;
    	}
    	
    	return n;
    }
    
  • 相关阅读:
    MVC ActionResult JsonResult
    xml文件
    使用socket实现聊天功能
    使用多线程完成Socket
    Socket编程
    U1总结
    多线程
    IO
    单例模式
    日期
  • 原文地址:https://www.cnblogs.com/icenter/p/2100528.html
Copyright © 2011-2022 走看看