PDA

View Full Version : Treepanel expand/collapse on a node without children



sowmyaranjan
22 Jan 2014, 3:13 AM
Hello

I am using ExtJs 4.2.How to show the collapse/expand icon on a node without children in a tree panel.On expand and collapse it should fire all the events related to the tree pane.

I tried adding

1-children:[{}] gave me undefined property.
2-loaded:true nothing happend
3-singleExpand:true nothing happend


Can any one please help on this.Special request to Sencha support team.

mdnaveed42
22 Jan 2014, 11:10 PM
Hi,

You need to use children: [], below is the sample code...


var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "detention", leaf: true },
{ text: "homework", expanded: true, children: [] },
{ text: "buy lottery tickets", leaf: true }
]
}
});


Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
renderTo: Ext.getBody()
});


Hope this helps :)

Thanks,
Md Naveed

sowmyaranjan
23 Jan 2014, 4:08 AM
I tried the above but its not showing the expand/collapse icon whose having empty children.

Gary Schlosberg
23 Jan 2014, 10:12 AM
I'm not sure this can be done, as I don't believe it's designed to display that way. That said, I was able to get the expand icon to display by removing the 'children' config entirely, but no collapse (minus) icon appears when it is expanded.

LesJ
23 Jan 2014, 10:14 AM
Did you try leaf false?

sowmyaranjan
23 Jan 2014, 10:31 AM
i tried leaf:false as well but it didnt work. So it means there are some limitations.

LesJ
23 Jan 2014, 10:33 AM
Did you try leaf: false and children:[] together?

Gary Schlosberg
23 Jan 2014, 2:17 PM
My understanding is that it is the plus/minus icons are desired, despite the lack of child nodes, which doesn't seem possible. Apologies if I misunderstood.

new2ext
23 Jan 2014, 2:22 PM
In the node config, set
allowChildren: true and leave off
children: [].