PDA

View Full Version : Add an attribute to a Ext.tree.TreeNode



Grimsk
30 Jul 2007, 7:41 AM
I want to add an attribute to all object from "Ext.tree.TreeNode"...

the original class is :


Ext.tree.TreeNode = function(attributes){
attributes = attributes || {};
if(typeof attributes == "string"){
attributes = {text: attributes};
}
this.childrenRendered = false;
this.rendered = false;
this.isTarget = attributes.isTarget !== false;
...
this.text = attributes.text;
....

i need to add the attributes "type" that i receive in params ( attributes.type )
....
later in my application i need to use ... myTreeNode.type ...

so .. what is the best way to add the attributes type.. ?

matjaz
30 Jul 2007, 9:12 AM
when you creating nodes just add type attribute to and then you can access it myTreeNode.attributes.type

para
30 Jul 2007, 9:24 AM
Anything that you add to the config of the new node will be put into node.attributes.



var newNodeConfigs = {text:"Hello", type:"export", ... };
var node = new Ext.tree.TreeNode(newNodeConfigs);
var type = node.attributes.type;

Grimsk
30 Jul 2007, 9:35 AM
thnks ;)

battisti
31 Jan 2008, 9:18 AM
it's great thx