Ext.onReady(function()...{ // shorthand var Tree = Ext.tree; var tree =new Tree.TreePanel(...{ el:'tree-div', useArrows:true, autoScroll:true, animate:true, enableDD:true, containerScroll: true, loader: new Tree.TreeLoader(...{ dataUrl:'Ajax.aspx' }) }); // set the root node var root =new Tree.AsyncTreeNode(...{ text: '总公司', draggable:false, id:'source' }); tree.setRootNode(root); // render the tree tree.render(); root.expand(); });
三 服务端代码
新建一个Ajax.aspx页面
using System; using System.Data; using System.Web; publicpartialclass Ajax : System.Web.UI.Page ......{ protectedvoid Page_Load(object sender, EventArgs e) ......{ string result ="[{"cls":"folder","id":10,"leaf":false,"children":[{"cls":"file","id":11,"leaf":true,"children":null,"text":"S600"},{"cls":"file","id":12,"leaf":true,"children":null,"text":"SLK200"}],"text":"业务部"}]"; Response.Write(result); } }