2 u012091381 u012091381 于 2013.10.12 00:17 提问

EXTJS4动态树无法加载

在书上找了一个EXTJS4动态树分级加载的实例
index.jsp


  • <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 动态树系统 Ext.onReady(function(){ Ext.regModel(&quot;OrgInfo&quot;,{ fields:[&#39;orgId&#39;,&#39;name&#39;,&#39;count&#39;] }); var myStore = new Ext.data.TreeStore({ model :&#39;OrgInfo&#39;, nodeParam : &#39;orgId&#39;, proxy: { type: &#39;ajax&#39;, url: &#39;treeServer.jsp&#39;, reader: &#39;json&#39;<br> }, autoLoad:true, root: { name:&#39;根结点&#39;, id: &#39;-1&#39; } });</li> </ul> <p>Ext.create(&#39;Ext.tree.Panel&#39;,{<br> title: &#39;分级异步加载树节点示例&#39;,<br> renderTo: Ext.getBody(),<br> width :250,<br> height :150,<br> columns: [{<br> xtype:&#39;treecolumn&#39;,<br> text:&#39;公司名称&#39;,<br> dataIndex:&#39;name&#39;,<br> width: 150,<br> sortable:true<br> },{<br> text:&#39;员工人数&#39;,<br> dataIndex:&#39;count&#39;,<br> flex: 1,<br> sortable: true<br> }],<br> store : myStore,<br> rootVisible: false<br> });</p> <p>});<br>





    这是前端的页面,可以正常显示
    然后是服务端的代码,也是一个JSP
    treeServer.jsp


    <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
    <%
    response.setContentType("utf-8");
    request.setCharacterEncoding("utf-8");
    response.setCharacterEncoding("utf-8");
    String orgId = request.getParameter("orgId");
    String result="";
    if("-1".equals(orgId)){
    result ="[{name:'总公司',count:100,id:100}]";
    }else if ("100".equals(orgId)){
    result = "[{name:'分公司一',count:20,id:110,leaf:true},{name:'分公司二',count:80,id:120}]";
    }else if("120".equals(orgId)){
    result = "[{name:'部门一',count:30,id:121,leaf:true},{name:'部门二',count:50,id:122,leaf:true}]";
    }
    response.getWriter().write(result);
    %>


    运行结果只有前端的一个框架,没有树和节点,在FIRFOX上查看审查后提示[{name:'总公司',count:100,id:100}]语法错误,可是实在不知道哪错了,请大家给看盾,我是新手,可以说都不怎么懂,还请说得明白一点,

Csdn user default icon
上传中...
上传图片
插入图片