PDA

View Full Version : Nodes missing from tree



fernando
25 Sep 2007, 12:32 PM
Hi guy's,

I'm trying to create a dynamic tree. But I'm not quite sure how to go about building it. Here is my Ext code:


Ext.onReady(function(){

var timTree = new Ext.tree.TreePanel('tree', {
animate:true,
enableDD:true,
containerScroll: true,
lines:false,
rootVisible:true,
loader: new Ext.tree.TreeLoader({
dataUrl:'treeData'})
});

var root = new Ext.tree.AsyncTreeNode({
allowDrag:false,

allowDrop:true,
id:'croot',
text:'Packages and Components',
cls:'croot',
loader:new Ext.tree.TreeLoader({
dataUrl:'treeData'
})
});


timTree.setRootNode(root);
timTree.render();
timTree.expandAll();

});


Here is my Rails code:


def treeData
@headers["Content-Type"] = "text/plain; charset=utf-8"
json = [{:text =>"folder", :id=>"1", :leaf=>"false", :children=>[
{:text=>"node1", :id=>"2", :leaf=>"true"}]
}]
render :text=>json.to_json, :layout=> false

end


and here is the response from the server:
[{leaf: "false", text: "folder", id: "1", children: [{leaf: "true", text: "node1", id: "2"}]}]

The above code only renders the first object("folder") which doesnt seem to have any children.
Can anyone tell me whats going on?

Cheers,