PDA

View Full Version : Expand node in Ext.tree.panel with children above the parent



parik
5 Nov 2012, 6:59 AM
I need to display the children of a particular node in a Treepanel above the parent node. I am using a 'Ext.tree.Panel' with multiple columns.

It should look like this :
39824


Also, this should happen only at the root level. Any intermediate nodes should retain the default behavior of expanding downwards.
Any help will be appreciated.
Thanks.

tvanzoelen
6 Nov 2012, 2:31 AM
treePanel.expandPath(nodeOfInterest.getPath())

parik
6 Nov 2012, 3:28 AM
This only lets you expand all the nodes and display a node within the tree. What I want is to change the default behavior of a node and make its children appear above the parent.

The images below might give a better idea

Initially:
39853
Default expanded behavior:
39856
What I need:
39854

Thanks.

tvanzoelen
6 Nov 2012, 3:35 AM
Then you set the display to hidden of the nodes you don't want to see

you can use this function for that


setDisplay: function(tree, node, visible) {


if (node) {
var record = tree.getStore().getNodeById(node.internalId);
var viewNode = Ext.fly(tree.getView().getNode(record));

if (viewNode) {

viewNode.setVisibilityMode(Ext.Element.DISPLAY);
viewNode.setVisible(visible);
}
}

}

So first expand the path you want to have and then set each node to disply false wich you do not wnat to see.

parik
6 Nov 2012, 10:23 PM
Thanks, I followed your method and am now able to hide the rows.