View Full Version : Async TreePanel with javascript function

30 Nov 2010, 1:49 AM
Hello everbody,

i got an problem as i tryed to reload data for a TreePanel. Normally you can set the "dataUrl" and the Tree will load the new data if you expand a node. In my way i will not call a URI to reload the data. I need to call a javascript function, which will give me the new data for the expanded node.
Is this possible? And has someone some example code for this problem?


30 Nov 2010, 2:00 AM
You can specify a directFn instead of a dataUrl in the TreeLoader config.

30 Nov 2010, 6:14 AM
Nice idea. But how can i give back the response for the tree? I have my TreeLoader configuration

loader: new Ext.tree.TreeLoader({
directFn: myfunc

and my function

function myfunc(elem, test)
return [{"text":"index.html","id":"\/index.html","leaf":true,"cls":"file"}];

the first argument in the function is the node id, the second a unknown function for me. But if i return a JSON Object nothing happens. In the documentation i only can read "Function to call when executing a request." No word about how returning a JSON Object for the node.