Hybrid View
-
22 Oct 2012 7:19 AM #1
TreePanel add children problem
TreePanel add children problem
Hi All,
i have this
but the array does'nt load...what is wrong?Code:var tree = new Ext.tree.TreePanel({ id:'treeTypeGraph', loader:new Ext.tree.TreeLoader(), width:200, height:400, renderTo:Ext.getBody(), root:new Ext.tree.AsyncTreeNode({ id:'root', expanded:true, leaf:false, text:'Tree Root', children:[] }) listeners: { render : function( _this) { load(); } }); function load(){ var arrChildrenTreeMP= new Array(); var aNode= new Ext.data.Node(); aNode.id= "cMP_1a"; aNode.text= "1 a"; var attr= new Array(); attr["code"]="code_n1a"; attr["desc"]="NODE 1 a"; aNode.attributes= attr; aNode.leaf= true; arrChildrenTreeMP[arrChildrenTreeMP.length]= aNode; var aNodea= new Ext.data.Node(); aNodea.id= "cMP_1b"; aNodea.text= "1 b"; var attra= new Array(); attra["code"]="code_n1b"; attra["desc"]="NODE 1 b"; aNodea.attributes= attra; aNodea.leaf= true; arrChildrenTreeMP[arrChildrenTreeMP.length]= aNodea; var root= Ext.getCmp('treeTypeGraph').getRootNode(); root.appendChild(arrChildrenTreeMP); Ext.getCmp('treeTypeGraph').doLayout(); }
-
29 Oct 2012 5:30 AM #2
New Code same problem
New Code same problem
Hi, with this new code
Ext.onReady(function(){
function loadArr(){
var rootNode= new Ext.tree.AsyncTreeNode({
id:'rootT',
expanded:true,
leaf:false,
text:'Tree Root'
})
var aNode= new Ext.data.Node();
aNode.nodeType= "node";
aNode.id= "cMP_1a";
aNode.text= "1 a";
aNode.leaf= true;
aNode.expanded= false;
rootNode.appendChild(aNode);
Ext.getCmp('treeTypeGraph').setRootNode(rootNode);
Ext.getCmp('treeTypeGraph').render();
//rootNode.expand(false, /*no anim*/ false);
}
var tree = new Ext.tree.TreePanel({
id:'treeTypeGraph',
loader:new Ext.tree.TreeLoader(),
width:200,
height:400,
renderTo:Ext.getBody()
,listeners: {
render: function(_this){
loadArr();
}
}
});
});
i have this problem:
TreeRoot.JPG
and if i uncomment this line:
//rootNode.expand(false, /*no anim*/ false);
i receive this error:
msg_error.JPG
Can someone help me?
Thanks in advance.


Reply With Quote