当前位置: 代码迷 >> J2EE >> ExtJS 动态加载树的有关问题请问
  详细解决方案

ExtJS 动态加载树的有关问题请问

热度:263   发布时间:2016-04-22 03:35:02.0
ExtJS 动态加载树的问题请教
在用ExtJS 动态加载树时的问题,
下载了ExtJS2.0.2版本的包,照着例子做的,自己做了三个文件:tree.js,tree.html,tree.txt
当运行时,只能看到树的根节点,而tree.txt中的文件都没加载进去,tree.txt的内容是安json来写的。
请高手们帮帮忙,我的问题在什么地方
===============================
tree.js
===============================
/*
 * Ext JS Library 2.0.2
 * Copyright(c) 2006-2008, Ext JS, LLC.
 * licensing@extjs.com
 * 
 * http://extjs.com/license
 */

Ext.onReady(function(){
  var Tree = Ext.tree;
  var tree = new Tree.TreePanel({
  el:'tree',
  loader: new Tree.TreeLoader({
  dataUrl:'tree.txt'
  })
  });

var root = new Ext.tree.AsyncTreeNode({id:"1",text:"根节点"});
//debugger;
  tree.setRootNode(root);

  // render the tree
  tree.render();
  root.expand();
});
-==============================================
tree.html
===============================================
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gbk">
<title>test tree111</title>
<link rel="stylesheet" type="text/css" href="../../resources/css/ext-all.css" />
  <!-- GC -->
  <!-- LIBS -->
  <script type="text/javascript" src="../../adapter/ext/ext-base.js"></script>
  <!-- ENDLIBS -->
  <script type="text/javascript" src="../../ext-all.js"></script>
<script type="text/javascript" src="testTreejs1.js"></script>

<!-- Common Styles for the examples -->
<link rel="stylesheet" type="text/css" href="../examples.css" />
</head>
<body>
<script type="text/javascript" src="../examples.js"></script><!-- EXAMPLES -->

<div id="tree" style="overflow:auto; height:300px;width:250px;border:1px solid #c3daf9;"></div>

</body>
</html>
============================================
tree.txt
============================================
[
  {id:"10",text:'01',children:[
  {id:"101",text:'01-01',leaf:true},
  {id:"102",text:'01-02',children:[
  {id:"1011",text:'01-02-01',leaf:true},
  {id:"1012",text:'01-02-02',leaf:true}
  ]},
  {id:"102",text:'01-03',leaf:true}
  ]},
  {id:"20",text:'02',leaf:true}
]



------解决方案--------------------
<script type="text/javascript" src="tree.js"></script> 
js引用不对!
  相关解决方案