zoukankan      html  css  js  c++  java
  • Ext中tree的研究

    新建一棵树

    var Tree = Ext.tree;    
    var tree1 = new Tree.TreePanel({
        el:'tree
    -content-div',
        border:
    false,
        autoScroll:
    true,
        animate:
    true,
        enableDD:
    true,
        containerScroll: 
    true,
        rootVisible:
    false,
      loader: 
    new Tree.TreeLoader({
            dataUrl:'RemoteHandlers
    /GetContentMenu.aspx'
         }
    )
    }
    );                            
    tree1.on('click', 
    function (node){    
    if(node.isLeaf()){
       Ext.get('center
    -iframe').dom.src = node.attributes.hrefTarget; }
    else{
       node.toggle(); }
      
    }
    );
                
    //tree1.on('beforeload', function (node){ 
    //
    tree1.loader.dataUrl = 'RemoteHandlers/GetSystemMenu.aspx';
    //
    });
                
    var root1 = new Tree.AsyncTreeNode({
        text: '内容管理',
        draggable:
    false,
        id:'source1'
    }
    );
                        
    tree1.setRootNode(root1);
    tree1.render();
    root1.expand();

    rootVisible:指是否显示根节点


    #2008-04-21#
    TreeLoader其实就是一个类似JSON的数据
    关于JSON的生成,其实网上有很多现成的类可以使用,大家可以到http://www.json.org/去看看,里面有针对不同的语言的生成方式等!
    但是要注意的是JSON数据的字段名称的单引号或者双引号不能要,如:

    strs.Append("["); 
    foreach (ModuleType mt in ilModuleType) 

    strs.Append(
    "{"); 
    strs.Append(
    "id:'" + mt.Id + "',"); 
    strs.Append(
    "text:'" + mt.Name + "',"); 
    strs.Append(
    "leaf:false"); 
    AddSubNodes(mt, s, strs); //添加子节点
    strs.Append(
    "},"); 
    }
     
    tmp 
    = strs.ToString(); 
    tmp 
    = tmp.Replace("}{""},{"); 
    tmp 
    = (tmp.Substring(tmp.Length - 1== ","? tmp.Substring(0,tmp.Length-1)+"]" : ""

    注意:上面的ModuleType 和 ilModuleType都是我的对象或者变量

  • 相关阅读:
    CCNA 6.9
    CCNA 6.5
    Google search
    CCNA 4.14 TP Correction
    CCNA 6.3
    CCNA 6.6
    有关 英语学习的一些网站
    法语学习笔记
    垃圾邮件分类(Scala 版本)
    SQL 面试经典问题 行列互相转化
  • 原文地址:https://www.cnblogs.com/pyonline/p/930441.html
Copyright © 2011-2022 走看看