View Full Version : TreeNode loosing ownerTree and parentNode in selectPath call

29 Jun 2008, 8:17 AM
Hi folks

I 'm using the version 2.1 and yesterday I had a lot of problems dealing with TreePanel and TreeNode...

I had this code:

node = getChildNodeRecursive(ddlTasks.getValue(), taskTree.root);

function getChildNodeRecursive(id, node) {
var child = node.findChild('id', id);
if (!child) {
for (var i = 0; i < node.childNodes.length; i++) {
child = getChildNodeRecursive(id, node.childNodes[i])
if (child) { return child; }
return child;

taskTree is a TreePanel.

Everything was fine until node.ensureVisible(). The problem is that node (I don't know exactly why) had its ownerTree and parentNode = null!!! I went to findChild code and make this change:

findChild : function(attribute, value){
var cs = this.childNodes;
for(var i = 0, len = cs.length; i < len; i++) {
if(cs[i].attributes[attribute] == value){
cs[i].ownerTree = this.getOwnerTree();
cs[i].parentNode = this;
return cs[i];
return null;

So, my node, after calling to getChildNodeRecursive(ddlTasks.getValue(), taskTree.root) now had a ownerTree and a parentNode, but after calling node.getPath(), I loose the ownerTree and parentNode again!!!

Another problem: if you try call node.ensureVisible() and the node was not rendered, you get an exception, because node.ui.anchor is undefined, of course. So, I included
if (!this.rendered) { this.render(); } at the first line of TreeNode.ensureVisible().

But, my problem are that node.render() doesn't work whitout a valid node.ownerTree and node.parentNode, which was loosed in the node.getPath() call. That was I think at first, but when I change the getPath to garantee that my node dont't get changed, I still had have the same error.

At this time I look at the TreePanel.selectPath() method... and I give up :(. There are a lot of ramifications and I haven't time to try to understand in which point the ownerTree and parentNode was missing.

To solve my problem, I put a new call to node = getChildNodeRecursive(ddlTasks.getValue(), taskTree.root); before node.ensureVisible(), which are very ugly and undesire. (here in Brazil we call this cod code)

This code is part of a ComboBox with a TreePanel. I need this problem fixed before publishing the entire code. Please... anyone heeelp me... :D

28 Aug 2008, 12:58 PM
I have the same problem as you do and I do not have an explanation for it either.

8 Jan 2009, 1:54 AM
Hi there!

Did you fixed?