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?

3
  • Did you check your DevTools console?. Were there any errors? Commented Jul 26, 2016 at 11:52
  • i think this will help you : stackoverflow.com/questions/13952140/extjs-treestore-with-proxy Commented Jul 26, 2016 at 12:53
  • my return is a type of string that contains {"success":true,"children":[]} but it also do not work. and i also try the type of jsonobject ,it does not work Commented Jul 26, 2016 at 15:22

1 Answer 1

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>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.