extjs3 树构建

用extjs3 创建一棵树需要注意一点:动态创建树时,返回的树节点应该是一个json数组。

以下是我用exttag创建的树,以及生成后的代码。

<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="ext" uri="/exttag"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<base href="<%=basePath%>">
<ext:ext title="tree录"> 
	<ext:viewport layout="fit">
		<ext:items>
			<ext:tabPanel activeTab="mytree" >
				<ext:items>
				<ext:treePanel  id="mytree" layout="fit" frame="true"    title="ok" >
					<ext:asyncTreeNode id="0"  text="你好"  ></ext:asyncTreeNode>
					<ext:treeLoader  url="/auth/tree.do" dataUrl="/auth/tree.do"   ></ext:treeLoader>
				</ext:treePanel>
				<ext:panel  id="d1222" title="haha " >
				
				</ext:panel>
					
				</ext:items>
			</ext:tabPanel>
		</ext:items>
	</ext:viewport>

</ext:ext>

 

<base href="http://127.0.0.1:8080/">
<html><head><title>tree录</title><link rel="stylesheet" type="text/css" href="ext-3.0.0/resources/css/ext-all.css" /><script type="text/javascript" src="ext-3.0.0/adapter/ext/ext-base.js"></script><script type="text/javascript" src="ext-3.0.0/ext-all.js"></script><script type="text/javascript" src="ext-3.0.0/src/locale/ext-lang-zh_CN.js"></script></head><body><script type="text/javascript">Ext.onReady(function() {Ext.QuickTips.init();Ext.state.Manager.setProvider(new Ext.state.CookieProvider());
 
	new Ext.Viewport({layout:"fit"

		,items: [

			new Ext.TabPanel({activeTab:"mytree"

				,items: [

				new Ext.tree.TreePanel({layout:"fit",id:"mytree",title:"ok",frame:true

					,root: new Ext.tree.AsyncTreeNode({text:"你好",id:"0"
})

					,loader: treeLoader0

				})

				,new Ext.Panel({id:"d1222",title:"haha "
})

					
				]

			})

		]

	})


});   var treeLoader0 = new Ext.tree.TreeLoader({dataUrl:"/auth/tree.do?textField=&idField=&leafField=&clsField=&childrenField=",url:"/auth/tree.do?textField=&idField=&leafField=&clsField=&childrenField="});</script><style type="text/css"></style></body></html>

 

[{"id":1000,"parentid":0,"text":"用户权限","leaf":false,"children":[
{"id":1001,"parentid":1000,"text":"登录","leaf":true,"children":null,
"url":"/admin/login.html"},{"id":1002,"parentid":1000,"text":"系统代码配置",
"leaf":true,"children":null,"url":"/ecpBaseCode/query/pagelist.html"}],
"url":""}]

 

展开阅读全文

没有更多推荐了,返回首页