TreePanelTest.html
<html>
<head>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
<script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
<script type="text/javascript" src="../../ext-all.js"></script>
<script language="javascript" type="text/javascript">
Ext.onReady(function(){
var tree = new Ext.tree.TreePanel({
animate : true,
autoScroll : true,
loader : new Ext.tree.TreeLoader({
baseParams : {
myName : "Dangzhao"
},
clearOnLoad : false ,
dataUrl : "http://127.0.0.1:8080/CommonWeb/jsonData.jsp" ,
listeners : {
beforeload : function(){alert("beforeLoad")},
load : function(){alert("load")},
loadexception : function(){alert("loadexception")}
},
preloadChildren : false,
requestMethod : "POST"
}),
el : 'tr',
enableDD:true
});
var root = new Ext.tree.AsyncTreeNode({
text: 'Tree Root',
draggable:false,
id:'0'
});
tree.setRootNode(root);
tree.render();
})
</script>
</head>
<body>
<div id="tr" style="width:300;height:400;top:40;left:120;position:absolute "></div>
</body>
</html>
jsonData.jsp
<%@page import="java.util.*" %>
[{
id: 1,
text: 'A Folder Node',
leaf: false
},{
id: 2,
text: 'A leaf Node',
leaf: true
}]
<%
Enumeration enm=request.getHeaderNames();
while(enm.hasMoreElements()){
String key=(String)enm.nextElement();
System.out.println(key+":"+request.getHeader(key));
}
Map p=request.getParameterMap();
Iterator it=p.keySet().iterator();
while(it.hasNext()){
String key=(String)it.next();
System.out.println(key+":"+((String[])p.get(key))[0]);
}
%>
System.out Information
Accept:*/*
Accept-Language:zh-cn
Referer:file://E:\ext-2.0.2\ext-2.0.2\examples\grid\TreePanelTest.html
x-requested-with:XMLHttpRequest
Content-Type:application/x-www-form-urlencoded
Accept-Encoding:gzip, deflate
User-Agent:Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host:127.0.0.1:7001
Content-Length:22
Connection:Keep-Alive
Cache-Control:no-cache
Cookie:2=1; 74=1; JSESSIONID=LvpgLBNZ!-832179795
node:0
myName:Dangzhao
Show 一下Ext Tree的魅力