开发者社区> 问答> 正文

extjs 4 tree能请求到数据,但是不显示,这是API中code

Java代码 收藏代码

Ext.define('Person', {  
        extend: 'Ext.data.Model',  
        fields: [  
            { name: 'id', type: 'int' },  
            { name: 'name', type: 'string' }  
        ],  
        proxy: {  
            type: 'ajax',  
            api: {  
                create: 'createPersons',  
                read: 'getData.jsp',  
                update: 'updatePersons',  
                destroy: 'destroyPersons'  
            }  
        }  
      
    });  
Ext.onReady(function(){  
    var store = Ext.create('Ext.data.TreeStore', {  
        model: 'Person',  
        root: {  
            name: 'People',  
            expanded: true  
        }  
    });  
      
    Ext.create('Ext.tree.Panel', {  
        renderTo: Ext.getBody(),  
        width: 300,  
        height: 200,  
        title: 'People',  
        store: store,  
        columns: [  
            { xtype: 'treecolumn', header: 'Name', dataIndex: 'name', flex: 1 }  
        ]  
    });  
});

Java代码 收藏代码

<%@ page language="java" contentType="application/json; charset=UTF-8" pageEncoding="UTF-8"%>  
<%     
    String result = "{'root':'People','success':true,'children':[{'id': 1,'name':'Phil','leaf':true},{'id':2,'name':'Nico','expanded':true,'children':[{'id':3,'name':'Mitchell','leaf':true}]},{'id':4,'name':'Sue','loaded':true}}";  
    System.out.println("sss");  
    out.write(result);  
    response.getWriter().write(result);  
%>

String result = "{'success':true,'children':[{'id': 1,'name':'Phil','leaf':true},{'id':2,'name':'Nico','expanded':true,'children':[{'id':3,'name':'Mitchell','leaf':true}]},{'id':4,'name':'Sue','loaded':true}}";

展开
收起
长安归故里. 2020-01-08 16:27:30 930 0
1 条回答
写回答
取消 提交回答
  • 一般是css引用不对造成的 renderTo:改为一个dom id试试 例如:renderTo:"demojava" 那么需要

    2020-01-08 16:27:40
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
CUDA MATH API 立即下载
API PLAYBOOK 立即下载
传统企业的“+互联网”-API服务在京东方的实践 立即下载