PDA

View Full Version : [1.1.1] Tree AsyncNodes and TreeNodes



bemeall
15 Oct 2007, 6:26 AM
As I'm developing an application with extjs, i've got some issue now.

I've got a tree, loading his nodes with a treeloader from a php script providing json data.
Working perfectly well.

But now comes the problem, if I want to add a node to this tree manually, it doesn't work.
So on the tree loaded with the treeloader, i'm adding a normal TreeNode to the root node with the appendChild method. It doesn't work if I do both treeloader and manual. If I choose one of them, it works well.

I've tried both the treeloader on the treepanel and on the rootnode as well, I can't get the combination of both work together.

Maybe anyone had this issue before, or can give me a hint in the right direction?

Thanks!

bemeall
15 Oct 2007, 11:54 PM
Just tested it with the 2.0 tree example, has the same problem for me. Maybe it's by design and do I have to look foor a workaround?

Code is almost the same as the tree example (in this case with the treeloader on the root node, tried both):

Tree


var tree = new Tree.TreePanel('tree-div', {
animate:true,
enableDD:true,
rootVisible : false,
loader: new Tree.TreeLoader(),
containerScroll: true
});


Root node


var root = new Tree.AsyncTreeNode({
loader: new Tree.TreeLoader({
dataUrl:'index.php?action=gettree'
}),
text: 'Website',
draggable:false,
editable:false,
id:'source'
});


Extra TreeNode (the piece of code that doesn't work with a treeloader specified)


var node = new Tree.TreeNode({
text: 'test',
id: 'test'
});
root.appendChild(node);


Tree rendering


tree.setRootNode(root);
tree.render();
root.expand();

bemeall
24 Oct 2007, 11:23 PM
Still haven't found a solution for this problem :(
Tried some things, but haven't found things that made a difference.

Did some other things that work amazing, but i'm stuck on this one...

MoShAn480
6 Nov 2007, 2:45 PM
Im having similar issue, but im not using tree loader. I have a tree whihc is created when the page loads, then i want to add more nodes to existing tree as the user executes certain tasks. The append does nto seem to be adding the nodes to my tree.

BernardChhun
6 Nov 2007, 5:47 PM
oy guys,

I've extensively worked with the TreePanel and y'all need to wait for the Tree loader's loading event to end before adding in new nodes.


tree.loader.on("load"
// wait for the load function to be launched
, function () {
// get a reference of the tree's root node.
var rt = this.getRootNode();
// create the new node
var node = new Ext.tree.TreeNode( {text: 'test',id: 'test'} );
// append it to the current root node
rt.appendChild(node);
}, tree, true
);

bemeall
8 Nov 2007, 1:56 AM
Looks like it works for me! If I place the treeloader on the tree itself, it is.
Needs some finetuning, but I think I'll get there myself ;)

Thanks!