View Full Version : Loading child nodes dynamically from different store/url than the parents Extjs 4.1

21 Feb 2013, 7:02 PM

I need help achieving this in Extjs 4.1:

1- Load parent nodes in Tree panel from URL "parentNodes/parentNodes.json"

parentNodes/parentNodes.json is:


2- Once user expands "ParentNode1" load its children from "ParentNode1/chiledNodes.json"

3- Once user expands "ParentNode2" load its children from "ParentNode2/chiledNodes.json"

Appreciate providing code example with the answer.


Fredric Berling
22 Feb 2013, 7:34 AM
I would put a listener on the "beforeload" event on the TreeStore.

In there you can change the proxys url accordingly before the call is made.

24 Feb 2013, 12:12 PM
Thanks Fredric, but in 'beforeload' event how do I know which parent node is expanding? so I can change the related URL to get the children of the current expanding parent node?

Can you please provide some code example?

Fredric Berling
25 Feb 2013, 7:14 AM
I was slightly wrong.. It the "beforeexpand" event you should be listening on .

listeners: {
beforeexpand: function (node) {
node.store.proxy.url = 'firstpart/' + node.getId() + '/secondpart'