PDA

View Full Version : Problem using tree inside accordion



coolrb
17 Jun 2009, 1:55 AM
Hi,
I am trying to use a tree in inside accordion and it is appearing properly. But clicking on any node, it simply keep on expanding tree by loading all child again. You might want to take a look the screenshot.
I am reusing border layout example and add the tree of Drag and Drop Reordering example inside west panel of border layout example. Please find my tree code.


Ext.onReady(function(){
// shorthand
var Tree = Ext.tree;

var tree = new Tree.TreePanel({
el:'tree-div',
useArrows:true,
autoScroll:true,
animate:true,
enableDD:false,
containerScroll: true,

// auto create TreeLoader
dataUrl: 'demo/sandbox.jsp',

root: {
nodeType: 'async',
text: 'Ext JS',
draggable:false,
id:'source'
}
});

// render the tree
tree.render();
tree.getRootNode().expand();
});

evant
17 Jun 2009, 1:57 AM
So, the tree works fine outside the accordion? What data is your page returning? Look at it in Fbug.

coolrb
17 Jun 2009, 3:08 AM
Yes it works fine outside the accordion.
I just copied data from one of example and please find below

[{"text":"build","id":"\/build","cls":"folder"},{"text":"INCLUDE_ORDER.txt","id":"\/INCLUDE_ORDER.txt"
,"leaf":true,"cls":"file"},{"text":"ext-core.js","id":"\/ext-core.js","leaf":true,"cls":"file"},{"text"
:"air","id":"\/air","cls":"folder"},{"text":"source","id":"\/source","cls":"folder"},{"text":"adapter"
,"id":"\/adapter","cls":"folder"},{"text":"examples","id":"\/examples","cls":"folder"},{"text":"docs"
,"id":"\/docs","cls":"folder"},{"text":"ext-all.js","id":"\/ext-all.js","leaf":true,"cls":"file"},{"text"
:"license.txt","id":"\/license.txt","leaf":true,"cls":"file"},{"text":"ext-core-debug.js","id":"\/ext-core-debug
.js","leaf":true,"cls":"file"},{"text":"ext-all-debug.js","id":"\/ext-all-debug.js","leaf":true,"cls"
:"file"},{"text":"resources","id":"\/resources","cls":"folder"},{"text":"CHANGES.html","id":"\/CHANGES
.html","leaf":true,"cls":"file"}]

Animal
17 Jun 2009, 3:17 AM
Yes it works fine outside the accordion.

I would think it behaves in the same way.

It passes to the server, the ID of the node for which it is requesting child nodes.

The server must then respond with the correct list of child nodes.

It is your server which is responding incorrectly, always sending the same set of child nodes.

coolrb
17 Jun 2009, 3:19 AM
I removed ids from tree and tree started working of collapsing the node, which was earlier not working. But then it still loads the whole tree as child of current node on click it not a leaf node.

Animal
17 Jun 2009, 3:23 AM
It's your server which is telling it what to load. You have a bug.

coolrb
17 Jun 2009, 3:31 AM
Thanks. Then how can I make TreeLoader customizable and send parameters to server to return values based on parameter like nodename

Animal
17 Jun 2009, 3:42 AM
It currently sends the node's ID.

If you want to make it send other params, use a beforeload listener.

As explained and shown in the docs.

coolrb
17 Jun 2009, 4:02 AM
Thanks, you are the man. Its much easier than I have thought. it seems to be better go thru all documentation.

Thanks dude.