PDA

View Full Version : Child node wont appear in the tree panel



Ashw!n
11 Feb 2011, 8:06 AM
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Checkbox TreePanel</title>
<link rel="stylesheet" type="text/css" href="../lib/Ext/resources/css/ext-all.css"/>
<!-- LIBS -->
<script type="text/javascript" src="../lib/Ext/adapter/ext/ext-base.js">
</script>
<script type="text/javascript" src="../lib/Ext/ext-all.js">
</script>
</style>
</head>
<body>
<script type="text/javascript">
Ext.onReady(function(){
var root = new Ext.tree.AsyncTreeNode({
text: "BlackHawk",
draggable: false,
id: 'source'
});


var childNode = new Ext.tree.TreeNode({
text: "child1",
id: "child1",
leaf: true
});


var treePanel = new Ext.tree.TreePanel({
useArrows: true,
autoScroll: true,
animate: true,
enableDD: true,
containerScroll: true,
border: false,
loader: new Ext.tree.TreeLoader(),
root: root,
});

treePanel.getRootNode().appendChild(childNode);
console.log(treePanel.getRootNode());
treePanel.render('tree-div');
treePanel.getRootNode().expand();
});
</script>
<div id="tree-div">
</div>
</body>
</html>



Hello , trying to create a tree panel with a child node, I could not do it programatically. Please let me know what I am missing?

Condor
12 Feb 2011, 4:17 AM
The root is an AsyncTreeNode, so it will load when expanded.

You have two options:
1. Change the root to a TreeNode so it doesn't do loading.
2. Configure the loader with clearOnLoad:false, so it doesn't clear your child node before loading.

Ashw!n
16 Feb 2011, 3:21 PM
That works.