PDA

View Full Version : Load tree nodes from different URLs in Tree panel



extdev22
13 Feb 2013, 3:16 AM
Extjs 4.1

Hi, here is what I want help to achieve:

1- Load parent nodes by ajax request to a json file e.g. URL of the parent nodes json file is parentNodes.json
[
{"id":1,"text":"Node1","url":"","depth":"0","path":"Node1/node1Childern.json"},

{"id":2,"text":"Node2","url":"","depth":"0","path":"Node2/node2Childern.json"}
]

2- Once the parent nodes loaded then on parent node expand (when user clicks to expand the parent node) need to load some other nodes as children of the this parent node by ajax request to a different json file.

e.g. URL for Node1 children Node1/node1Childern.json
[
{"id":3,"text":"Node1Child1","url":"123.html","depth":"1"},

{"id":4,"text":"Node1Child2","url":"456.html","depth":"1"}
]

e.g. URL for Node2 children Node2/node2Childern.json
[
{"id":5,"text":"Node2Child1","url":"abc.html","depth":"1"},

{"id":6,"text":"Node2Child2","url":"efg.html","depth":"1"}
]

please note that the "path" in parent node used as the path of the json file for child nodes.

Thanks,

mitchellsimoens
14 Feb 2013, 9:12 PM
You could listen to the beforeload event and change the url

extdev22
18 Feb 2013, 12:07 AM
Thanks for the answer,

In the beforeload event handler I still can't get the expanded node to know what URL to change to, could you please post some example code showing how to capture the node, and I think I need to access the tree store proxy URL config to change it (Ext.data.proxy.Ajax what I'm using).

Nameer