PDA

View Full Version : TreePanel not loading empty branches.



dajohnson1s
16 Aug 2010, 7:31 AM
Hello,

I am loading a TreePanel via JSON, when the tree encounters a branch with no children, the tree acts as if it is a leaf. What in the tree actually deterimines if a node is a leaf or a branch? And how does this impact what 'icon' is shown?

Here is my tree:



var checkTree = new Ext.tree.TreePanel( {
renderTo:'checkTree',

autoScroll:true,
rootVisible:true,
useArrows: true,
width:300,
height:450,

loader: new Ext.tree.TreeLoader( {

url: 'act_getElementList.php',
nodeParameter: 'leftMenuID',
// Parameters passed.
baseParams: {
campusID: 1
}
} ),

root:{
nodeType: 'async',
id: '0',
text: 'Ext JS',
expanded: true,
draggable: false

}
});


Here is the json I am using ( generated from the php file ):


[
{
"text":"Cat 1",
"id":"3",
"leaf":false,
"cls":"folder",
"children":[
{
"text":"asdf",
"id":"154",
"leaf":false,
"cls":"folder",
"children":[]
},{
"text":"fafasfsadfa",
"id":"174",
"leaf":false,
"cls":"folder",
"children":[]
}
]
}
]


Thanks in advance.

ashaihullin
16 Aug 2010, 8:46 AM
leaf: true - means that there cannot be any children after this node. It final node... if there're no children you should make leaf = true

dajohnson1s
16 Aug 2010, 3:19 PM
ashaihullin

Thanks for the comment. I actually am doing that.

What I have realized though, and I am not sure why this is happening, when using the loader the JSON loads the nodes differently than when I add a 'children: ' property to the root object ( not using the loader ). What I mean is when I copy the JSON that is returned from the php file as noted in my first post and do the children property...this solves my problem.

But I am not sure how to get the same effect while using the php file.