PDA

View Full Version : Treepanel get Node childs without expandAll



eldioni
16 Sep 2009, 7:09 AM
Hi everybody. I have a question.
I have a Treepanel defined like this:

oTree = new Tree.TreePanel(
{
region: 'center',
el: 'tree-dive',
.
.
loader: new Tree.TreeLoader({dataUrl:'getnodes.php'}),
collapsed: false,
collapsible: true
}
var oRoot = new Tree.AsyncTreeNode({
text: 'Menu',
draggable:false,
expanded: true,
id:'root-0'
});
oTree.setRootNode(oRoot);
Now what I want to do is this: on some of the leaf of that treepanel (does not really matter where) I want a context menu to show up listing all the child nodes of certain nodes of the tree, like this:


function GetNodesForContextMenu {
var ret = {'profiles': [], 'exams': []};
var PNode = oTree.getNodeById('profiles-0');
var PChilds = PNode.childNodes;

for(var i=0;i<PChilds.length;i++){
var pGroups = oTree.getNodeById(PChilds[i].id);
var pGroupsChilds = pGroups.childNodes;
var tmp = [];
for(var j=0;j<pGroupsChilds.length;j++){
tmp.push({id: pGroupsChilds[j].id, text: pGroupsChilds[j].text});
}
ret['profiles'].push({id: PChilds[i].id, text: PChilds[i].text, menu: {items: tmp}});
}
return ret;
}
The problem is that pGroups.childNodes does not contain the child nodes until that node has being expanded.
I was reading the docs and found Treepanel.expand(), Treepanel.expandAll(), Node.eachChild() but none does what I need. I would need something like "virtually" expanding the child nodes of a given node without actually expanding them visually in the Tree.

Any help is greatly appreaciated.


Thanks

eldioni
17 Sep 2009, 11:55 AM
Anyone pls ?