View Full Version : Tree node icon
ssa962
31 Aug 2007, 12:19 AM
Is it possible to change the icon of the node dynamically? Like we can change the text of the node -
node.setText('Hello');
Animal
31 Aug 2007, 12:36 AM
http://extjs.com/deploy/ext-1.1.1/docs/output/Ext.tree.TreeNode.html#getUI
TreeNodeUI is not documented yet, but it has
getIconEl()
Which returns the icon element. You can change the class of that if you used iconCls:myIconClass, or change the src of it if you used icon:'http://foo'
vasmann
7 Oct 2007, 11:43 PM
http://extjs.com/deploy/ext-1.1.1/docs/output/Ext.tree.TreeNode.html#getUI
TreeNodeUI is not documented yet, but it has
getIconEl()
Which returns the icon element. You can change the class of that if you used iconCls:myIconClass, or change the src of it if you used icon:'http://foo'
Sorry for a stupid question.
I've read three or four threads about changing TreeNode icon dynamically.
My problem is:
I have TreePanel with nodes (representing contact list :-)), so, contact can change it's status (from available to free4chat for example), so I should represent it in the tree.
I have css file, where I have records like this
.x-contact-available
{
background-image: 'url(...)'
}
and have map (Array), which contains status key and it's value
map["available"] = "x-contact-available"; etc foreach status
and then when I see that contact's status changed, all I should do
contactNode.attributes.iconCls = map[contact.status]; (not working)
I tried
contactNode.ui.removeClass(map[oldstatus]);
contactNode.ui.addClass(map[contact.status]);
(not working);
also I tried
contactNode.ui.getIconEl().iconCls = ...
same result.
I use ExtJs 2.0 alpha
Using Firebug, look at which elements those actually are, and which classes they have.
It depends on how you're setting the icon in the first place, but if you are using the CLS config option, it will append that cls onto the main DIV element.
If this is the case, then try:
var cls = 'old-icon-class';
var cls2 = 'new-icon-class';
Ext.get(n.ui.elNode).removeClass(cls);
Ext.get(n.ui.elNode).addClass(cls2);
Powered by vBulletin® Version 4.1.5 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.