PDA

View Full Version : TreePanel: this.ctNode is undefined



Entropy
14 Jul 2009, 5:29 AM
My tree has been working fine as I have been putting it into my page and adding features and enhancing it. It lazy-loaded fine. Then, after making a variety of changes that I am not sure I can back out accurately and which I didn't expect to impact the tree directly (selection criteria, labelling, etc.), I suddenly noticed that my sub-nodes weren't loading anymore.


The issue seems to be that the nodeUI's ctNode property is undefined which causes a problem while loading. The JSON looks the same. Yet when I step through now, sure enough this.wrap.childNodes[] pretty much always has only one element, and so the ctNode is undefined.


Does anyone have any idea what/how I screwed up here? I presume ctNode means containerNode. Is that the parentNode? Should I just set it to that? But it wasn't like that when it was working, so that doesn't seem right.

Note that bulkRender seems to always be true, so the beforeEnd is the way wrap is set.




Ext.tree.ColumnNodeUI = Ext.extend(Ext.tree.TreeNodeUI, {
focus: Ext.emptyFn, // prevent odd scrolling behavior


renderElements :

function(n, a, targetNode, bulkRender){

this.indentMarkup = n.parentNode ? n.parentNode.ui.getChildIndent() : '';




var t = n.getOwnerTree();

var cols = t.columns;
var bw = t.borderWidth;
var c = cols[0];
var cb = typeof a.checked == 'boolean';
var buf;





buf = [

'<li class="x-tree-node"><div ext:tree-node-id="',n.id,'" class="x-tree-node-el x-tree-node-leaf x-unselectable ', a.cls,'" unselectable="on">',
'<div class="x-tree-col" style="width:',c.width-bw,'px;">',
'<span class="x-tree-node-indent">',this.indentMarkup,"</span>",
'<img src="', this.emptyIcon, '" class="x-tree-ec-icon x-tree-elbow">',
'', //'<img src="', a.icon || this.emptyIcon, '" class="x-tree-node-icon',(a.icon ? " x-tree-node-inline-icon" : ""),(a.iconCls ? " "+a.iconCls : ""),'" unselectable="on">',
cb ? (




'<input class="x-tree-node-cb" type="checkbox" ' + (a.checked ? 'checked="checked" />' : '/>')) : '',

'<a hidefocus="on" class="x-tree-node-anchor" href="',a.href ? a.href : "#",'" tabIndex="1" ',

a.hrefTarget ? ' target="'+a.hrefTarget+'"' : "", '>',
'<span unselectable="on">', n.text || (c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</span></a>",
"</div>"];





for(var i = 1, len = cols.length; i < len; i++){

c = cols[i];





buf.push('<div class="x-tree-col ',(c.cls?c.cls:''),'" style="width:',c.width-bw,'px;">',

'<div class="x-tree-col-text" style="' + n.attributes.style[i-1] + '">',(c.renderer ? c.renderer(a[c.dataIndex], n, a) : a[c.dataIndex]),"</div>",
"</div>");
}
// buf.push(
// '<div class="x-clear"></div></div>',
// '<ul class="x-tree-node-ct" style="display:none;"></ul>',
// "</li>");




if(bulkRender !== true && n.nextSibling && n.nextSibling.ui.getEl()){

this.wrap = Ext.DomHelper.insertHtml("beforeBegin",
n.nextSibling.ui.getEl(), buf.join(""));
}else{
this.wrap = Ext.DomHelper.insertHtml("beforeEnd", targetNode, buf.join(""));
}





this.elNode = this.wrap.childNodes[0];

this.ctNode = this.wrap.childNodes[1];
var cs = this.elNode.firstChild.childNodes;
//alert(cs[0] + " / " + cs[1] + " / " + cs[2] + " / " + cs[3]);
this.indentNode = cs[0];
this.ecNode = cs[1];
//this.iconNode = cs[2];
var iAnchor = 2;
if(cb)
{
this.checkbox = cs[2];
// fix for IE6
this.checkbox.defaultChecked = this.checkbox.checked;
iAnchor=3;
}
this.anchor = cs[iAnchor];
this.textNode = cs[iAnchor].firstChild;
}


});

Entropy
14 Jul 2009, 9:03 AM
Nevermind. I don't remember commenting out that buf.push that closed this list item, and so didn't scrutinize it, but that was the problem...obviously.