tree.js
Ext.onReady(function(){ //通过json取树 var root = new Ext.tree.AsyncTreeNode({ id:'root', text:'树的根', href:'http://www.baidu.com' //根节点链接 }); var loader= new Ext.tree.TreeLoader({url:'treedata.js'}); //从js文件里取得json数据 var tree = new Ext.tree.TreePanel({ renderTo:'tree-div', root:root, loader:loader, 200 }); /*tree.on('click',function(node,event){ //节点响应事件 alert(node.text); });*/ //tree.render(); });
treedata.js
[{ id:'1', text:'子节点1', leaf:true }, { id:'2', text:'子节点2', children:[{ id:'3', text:'孙子节点', leaf:'true' } ] } ]