PDA

View Full Version : [OPEN] [CLOSED][3.0.0] treeNode.appendChild works only when node is expanded



dolittle
2 Sep 2009, 4:01 PM
ext-3.0.0

appendChild to a tree node works only when the node is expanded.

Drop this code instead of reoder.js in the /examples/tree
The button 'add' should add a node but only if you'll remove the comment
from the last line it'll work.

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

var tree = new Tree.TreePanel({
tbar: [{
text: 'add',
handler: function(){
tree.getRootNode().appendChild({
text: 'child'
});
}
}],
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
// auto create TreeLoader
dataUrl: 'get-nodes.php',

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

// render the tree
tree.render('tree-div');
//tree.getRootNode().expand();
});

Condor
2 Sep 2009, 11:19 PM
This is not a bug.

An AsyncTreeNode will load it's children from the TreeLoader when expanded (and replace any existing children).

You have several options:
1. Define the root as nodeType:'node' (create a TreeNode instead of a AsyncTreeNode).
2. Define the root as loaded:true (already loaded, so expand will only show existing children).
3. Define the loader as clearOnLoad:false (don't remove existing children when loading).

dolittle
3 Sep 2009, 12:38 AM
This is not a bug.

An AsyncTreeNode will load it's children from the TreeLoader when expanded (and replace any existing children).

You have several options:
1. Define the root as nodeType:'node' (create a TreeNode instead of a AsyncTreeNode).
2. Define the root as loaded:true (already loaded, so expand will only show existing children).
3. Define the loader as clearOnLoad:false (don't remove existing children when loading).


If I'm uding loaded:true then the node has an 'item icon' instead of a folder icon
that's why I define the root as:

'root': {
text: 'nodeName',
id: 'src',
children: []
}
In that way the node icon is a folder and it thinks it already loaded its children.
nodeType didn't have an effect.

Maybe the node icon should be a folder unless you set it as leaf and is the bug?

Condor
3 Sep 2009, 12:56 AM
A loaded non-leaf node without child nodes will be displayed as a leaf unless you set it to expandable:true.

dolittle
3 Sep 2009, 1:21 AM
I think that in this case it should be a folder but expandable:true works for me
you can close this issue

Thanks