我通过动态加载数据来创建ExtJS树,js代码在
之下var treeModel = Ext.define("TreeModel", {
extend : "Ext.data.Model",
fields : [{id: "id", type : "string"},
{name : "text", type : "string"},
{name : "leaf", type : "boolean"}]
});
var store = new Ext.data.TreeStore({
model: 'treeModel',
proxy: {
type: 'ajax',
url: 'listtreecontent.action'
},
root: {
expanded: true
},
reader: {
type: 'JSON',
root: 'array'
},
autoLoad:true
});
var treePanel = new Ext.tree.TreePanel({
title: 'Data management',
width: 500,
height: 300,
renderTo: Ext.getBody(),
useArrows: true,
rootVisible: false,
store: store
});
但它没有显示树
我可以获得响应数据, response data
当我将响应数据写入json文件,并让url = jsonfile地址时,它可以显示树,我不知道为什么?
答案 0 :(得分:0)
也许在struts2中,我们应该为动作设置一个参数
<action name="listtreecontent" class="org.easygeoc.account.ListTreeContent" method="returnTreeNodes">
<result type="json">
<param name="root">array</param>
<param name="root">js</param>
</result>
</action>