PDA

View Full Version : tree without main/first node



lormitto
27 Feb 2010, 5:46 AM
Hi,

I tried to rebuild my menu like tree unfortunately without success.

Could you please taka a look at code:


text:'',
iconCls:'',
expanded: true,
children:[
{
text:'q',
id:'q',
icon: 'images/q.png',
leaf:true
},{
text:'z',
id:'z',
icon: 'images/z.gif',
leaf:true
},
{
text:'x',
id:'x',
leaf:true,
icon: 'images/x.png',

}
]
}]

I would like to see only children without main node but i do not know how to turn it of. I tried to build tree without children however i faild. Could you please advise any approach to this issue?


Thank you in advance.

BlueCamel
27 Feb 2010, 9:38 AM
You must have a root node, but you can hide the root node by default. The following example should help. See the docs for treepanel for more info.


var tree = new Ext.tree.TreePanel({
renderTo: 'tree-div',
autoScroll: true,
animate: true,
containerScroll: true,
border: false,
rootVisible: false,
lines: false,
root: {
nodeType: 'async',
text: 'root',
draggable: false,
id: 'root-node',
expanded: true,
children: [{
text:'q',
id:'q',
icon: 'images/q.png',
leaf:true
},{
text:'z',
id:'z',
icon: 'images/z.gif',
leaf:true
},{
text:'x',
id:'x',
leaf:true,
icon: 'images/x.png'
]}
}
});

lormitto
27 Feb 2010, 1:56 PM
Thank you very much for help.
I use your code and it works.

I tried to implement in json file but i failed. Fortunately putting tree in code directly is good for me as well.