PDA

View Full Version : Extending TreeNode/AsyncTreeNode Problem



mikecx
11 Sep 2008, 11:34 AM
For some reason I can't seem to get passed in config values to add a class when I override the TreeNode and AsyncTreeNode.



AAsyncNode = Ext.extend(Ext.tree.AsyncTreeNode, {
constructor: function(config) {
Ext.apply(this, {
pDisabled: false
});
AAsyncNode.superclass.constructor.apply(this, arguments);
if (this.attributes.pDisabled){
alert('async disable');
this.getUI().addClass("x-tree-node-disabled");
} else {
alert('async enable');
this.getUI().removeClass("x-tree-node-disabled");
}
},
psuedoEnable: function(){
this.getUI().removeClass("x-tree-node-disabled");
},
psuedoDisable: function(){
this.getUI().addClass("x-tree-node-disabled");
}
});

Ext.reg('AAsnycNode', AAsyncNode);

ANode = Ext.extend(Ext.tree.TreeNode, {
constructor: function(config) {
Ext.apply(this, {
pDisabled: false
});
ANode.superclass.constructor.apply(this, arguments);
if (this.attributes.pDisabled){
alert('disable');
this.getUI().addClass("x-tree-node-disabled");
} else {
alert('enable');
this.getUI().removeClass("x-tree-node-disabled");
}
},
psuedoEnable: function(){
this.getUI().removeClass("x-tree-node-disabled");
},
psuedoDisable: function(){
this.getUI().addClass("x-tree-node-disabled");
}
});

Ext.reg('ANode', ANode);
and



Ext.override(Ext.tree.TreeLoader, {
createNode: function(attr){
if(this.baseAttrs){
Ext.applyIf(attr, this.baseAttrs);
}
if(this.applyLoader !== false){
attr.loader = this;
}
if(typeof attr.uiProvider == 'string'){
attr.uiProvider = this.uiProviders[attr.uiProvider] || eval(attr.uiProvider);
}
if(attr.nodeType){
return new Ext.tree.TreePanel.nodeTypes[attr.nodeType](attr);
}else{
return attr.leaf ?
new ANode(attr) :
new AAsyncNode(attr);
}
}
});
The passed in JSON looks like:



[{"text": "Company", "leaf": false, "children": [{"text": "Corporate", "leaf": false, "children": [{"text": "Interns", "leaf": false, "children": [{"text": "blueray", "leaf": true, "pDisabled": true}, {"text": "tunabear", "leaf": true, "pDisabled": true}, {"text": "sunny", "leaf": true, "pDisabled": true}, {"text": "mossman", "leaf": true, "pDisabled": true}, {"text": "tacobill", "leaf": true, "pDisabled": true}], "pDisabled": true}, {"text": "Policy Analysts", "leaf": false, "children": [{"text": "hoopty", "leaf": true, "pDisabled": false}, {"text": "red", "leaf": true, "pDisabled": false}, {"text": "melissa", "leaf": true, "pDisabled": false}], "pDisabled": false}, {"text": "Interns", "leaf": false, "children": [{"text": "blueray", "leaf": true, "pDisabled": false}, {"text": "tunabear", "leaf": true, "pDisabled": false}, {"text": "sunny", "leaf": true, "pDisabled": false}, {"text": "mossman", "leaf": true, "pDisabled": false}, {"text": "tacobill", "leaf": true, "pDisabled": false}], "pDisabled": false}, {"text": "francesca", "leaf": true, "pDisabled": false}, {"text": "paul", "leaf": true, "pDisabled": false}, {"text": "Developers", "leaf": false, "children": [{"text": "prose", "leaf": true, "pDisabled": false}, {"text": "pinson", "leaf": true, "pDisabled": false}, {"text": "greg", "leaf": true, "pDisabled": false}, {"text": "miketv", "leaf": true, "pDisabled": false}, {"text": "randyjoe", "leaf": true, "pDisabled": false}, {"text": "jwhiz", "leaf": true, "pDisabled": false}], "pDisabled": false}], "pDisabled": false}, {"text": "Company", "leaf": true, "pDisabled": false}], "pDisabled": false}]

It alerts the proper enabled/disabled but doesn't apply the class.

I also tried using this.ui.addClass() and this.ui.removeClass() inside the if/else's with no change.