1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    4
    Vote Rating
    0
    s.welz is on a distinguished road

      0  

    Default Changeing IconCLS on a TreeNode

    Changeing IconCLS on a TreeNode


    Hi,

    im trying to change the IconCLS of a TreeNode onClick. There is a setText function but i cant find a way to swap the icon on the fly. There is node.attributes.iconCLS but changing this value has no effect at all ...

    So my Question is : Is there a way to rerender the Node or a function to change the IconCLS?

    Any suggestions ?

    With regards,
    Steven

  2. #2

  3. #3
    Ext User
    Join Date
    Apr 2008
    Posts
    4
    Vote Rating
    0
    s.welz is on a distinguished road

      0  

    Default


    ty =)

  4. #4
    Ext User
    Join Date
    Jun 2008
    Posts
    32
    Vote Rating
    0
    scottpenrose is on a distinguished road

      0  

    Default


    I had someone ask exactly this, plus I have done it myself before, so here is an easily reusable extensions:

    Code:
    Ext.override(Ext.tree.TreeNode, {
    	setIcon: function(src) {
    		var iel = this.getUI().getIconEl();
    		if (iel) {
    			var el = Ext.get(iel);
    			if (el) {
    				el.addClass('x-tree-node-inline-icon');
    				el.dom.src = src;
    			}
    		}
    	}
    });

  5. #5
    Sencha User
    Join Date
    Apr 2008
    Location
    Kyrgyzstan
    Posts
    4
    Vote Rating
    0
    elrevin is on a distinguished road

      0  

    Default


    Or you can add CSS class to the node's element:
    Code:
    	Ext.override(Ext.tree.TreeNode, {
    		setIconCls: function(iconClassName) {
    			var iel = this.getUI().getIconEl();
    			if (iel) {
    				var el = Ext.get(iel);
    				if (el) {
    					el.addClass(iconClassName);
    				}
    			}
    		}
    	});
    In *.css file:
    Code:
    .some-icon
    {
      background-image: url(images/some-icon.gif) !important;
    }

  6. #6
    Ext User
    Join Date
    Jun 2008
    Posts
    32
    Vote Rating
    0
    scottpenrose is on a distinguished road

      0  

    Default Git repository

    Git repository


    I have added the code combined from my own and elrevin here:

    http://github.com/scottp/ext-extend-...on/tree/master

    Enjoy.

    P.S. I have started (long way to go) getting all my code up on Github. As I do I will start adding demonstrations etc.

  7. #7
    Ext User
    Join Date
    Jan 2010
    Posts
    68
    Vote Rating
    0
    brk11 is on a distinguished road

      0  

    Default


    Have you find a workarround for the "second" icon class change?