PDA

View Full Version : Help, problem with TreePanel..



hcortez
28 Apr 2009, 8:22 AM
Hi, I have the following code ...


Ext.onReady(function(){
var datosJSON = [
{"text":"A","id":10,"leaf":false,"children":[
{"text":"B","id":11,"leaf":false},
{"text":"C","id":18,"leaf":false,"children":[
{"text":"D","id":19,"leaf":false,"children":[
{"text":"E","id":191,"leaf":true},
{"text":"F","id":191,"leaf":true}
]},
{"text":"G","id":20,"leaf":false},
{"text":"H","id":21,"leaf":false}
]}
]}
];

var Tree = Ext.tree;


var tree = new Tree.TreePanel('tree', {
animate:true,
enableDD:false,
loader: new Tree.TreeLoader(),// no need a url, but here is the problem
lines: true,
selModel: new Ext.tree.MultiSelectionModel(),
containerScroll: false
});
root = new Ext.tree.AsyncTreeNode({
text: 'Autos',
id:'source',
children: datosJSON
});
tree.setRootNode(root);
root.expand();
}

...my goal is to upload the data treePanel with JSON data type, but does not issue an error to put the TreeLoader () blank, someone can help me? /:)

Animal
28 Apr 2009, 8:33 AM
http://extjs.com/deploy/dev/docs/?class=Ext.tree.TreePanel&member=TreePanel

hcortez
28 Apr 2009, 11:55 AM
Sorry, but you could tell me if what I'm doing this right or not, or could give me a track to find the help because I can not find any solution...(:|

Animal
28 Apr 2009, 12:30 PM
API document. Read it. Compare to your code.

hcortez
29 Apr 2009, 12:57 PM
I succeed, I do not know if will be the best way but it works for me...


Ext.onReady(function(){
var datosJSON = [
{"text":"A","id":10,"leaf":false,"children":[
{"text":"B","id":11,"leaf":false},
{"text":"C","id":12,"leaf":false},
{"text":"D","id":18,"leaf":false,"children":[
{"text":"E","id":19,"leaf":false,"children":[
{"text":"F","id":191,"leaf":true},
{"text":"G","id":191,"leaf":true}
]},
{"text":"H","id":20,"leaf":false}
]}
]}
];


var root = new Ext.tree.TreeNode({
expanded:true,
text:'',
draggable:false,
id:'source',
cls:"folder",
children:datosJSON
});

new Ext.tree.TreeLoader({preloadChildren: true}).doPreload(root);

var Tree = Ext.tree;

var tree = new Tree.TreePanel({
id:'tree_id',
useArrows:true,
animate:true,
enableDD:true,
autoScroll:true,
border:false,
rootVisible:false,
root:root
});
});


thks for all:D