Extjs 静态tree

Ext.onReady(function(){
    Ext.QuickTips.init();
  var mytree=new Ext.tree.TreePanel({
      el:"container",
      animate:true,
      title:"Extjs静态树",
      collapsible:true,
      enableDD:true,
      enableDrag:true,
      rootVisible:true,
      autoScroll:true,
      autoHeight:true,
      width:150,
      lines:true
  });
 
  //根节点
  var root=new Ext.tree.TreeNode({
      id:"root",
      text:"控制面板",
      expanded:true
  });
 
  //第一个子节点及其子节点
  var sub1=new Ext.tree.TreeNode({
      id:"news",
      text:"新闻管理",
      singleClickExpand:true
  });
  sub1.appendChild(new Ext.tree.TreeNode({
      id:"addNews",
      text:"添加新闻",
      href:"http://www.baidu.com",
      hrefTarget:"mainFrame",
      qtip:"打开百度",
      listeners:{//监听
          "click":function(node,e){
                      alert(node.text)
                  }
      }
  }));
  sub1.appendChild(new Ext.tree.TreeNode({
      id:"editNews",
      text:"编辑新闻"
  }));
  sub1.appendChild(new Ext.tree.TreeNode({
      id:"delNews",
      text:"删除新闻"
  }));
 
  root.appendChild(sub1);
 
  root.appendChild(new Ext.tree.TreeNode({
        id:"sys",
        text:"系统设置"
  }));
 
  mytree.setRootNode(root);//设置根节点
 
  mytree.render();//不要忘记render()下,不然不显示哦
})

你可能感兴趣的:(ext,百度)