Results 1 to 3 of 3

Thread: TreeNode loosing ownerTree and parentNode in selectPath call

  1. #1

    Default TreeNode loosing ownerTree and parentNode in selectPath call

    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:
    Code:
    	node = getChildNodeRecursive(ddlTasks.getValue(), taskTree.root);
    	taskTree.selectPath(node.getPath());
    	node.ensureVisible();
    
    	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:
    Code:
    	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
    Code:
    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...

  2. #2
    Sencha Premium Member
    Join Date
    Jun 2008
    Posts
    381

    Default

    I have the same problem as you do and I do not have an explanation for it either.

  3. #3

    Default

    Hi there!

    Did you fixed?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •