0

i create a ExtJS tree by loading data dynamically, the js code is below

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

}); 

but it does not show the tree

i can get the response data, response data

when i write the response data into a json file, and let the url = jsonfile address, it can show the tree, i do not know why?

1 Answers1

0

maybe in the struts2, we should set a param for the action

<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>