PDA

View Full Version : TreePanel from asynchronous json response (folder path)



ssamuel68
11 Mar 2013, 12:56 PM
Hi,

First I was loading a tree panel with the "full" json structure, but I need to load the tree asynchronous.

The new json now is like this:


[ {"text": "Empty", "path": "/home/sam/Downloads/Empty"},
{"text": "Folder", "path": "/home/sam/Downloads/Folder"},
{"text": "testDoc3.txt", "path": "/home/sam/Downloads/testDoc3.txt", "leaf": true},
{"text": "testDoc4.txt", "path": "/home/sam/Downloads/testDoc4.txt", "leaf": true}
]

42309

So every time I open a folder it calls the store again to load the children.

How I can get the parameters to load the children?. Everytime I open a folder it loads the same tree because my json never change the response.

Thx

ssamuel68
11 Mar 2013, 1:02 PM
The code of the tree panel:



var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true
},
proxy: {
type: 'direct',
directFn: Test.getFtpTree,
paramOrder: ['node']
}
});

var tree = Ext.create('Ext.tree.Panel', {
store: store,
height: 350,
width: 600,
title: 'Tree Sample',
rootVisible: true
});

evant
11 Mar 2013, 1:13 PM
The node parameter gets passed to the server, it's up to you to interrogate it and return the appropriate children at that level.

There's examples of this in the SDK download.

ssamuel68
11 Mar 2013, 1:17 PM
I was using this example: http://docs.sencha.com/ext-js/4-1/#!/example/direct/direct-tree.html

B (http://docs.sencha.com/ext-js/4-1/#!/example/direct/direct-tree.html)ut I dont have the back end code.

evant
11 Mar 2013, 1:43 PM
It's in the SDK download.

ssamuel68
14 Mar 2013, 7:21 AM
My problem was that on my direct I set the number of parameters to 0, so in my controller I didnt receive the id of the node.

I change it to 1 and now I get the id of the node.