[CLOSED] Change icon on treenode from javascript

  1. #1

    [CLOSED] Change icon on treenode from javascript



    Hi
    I need to change the icon of a treeview node from javascript, I also want to know how to get the number of childNodes.

    I have a tree panel filled with nodes, i just want to loop throu them and thange the icon on some of them.

    See sample code
        <script type="text/javascript">
        function Test()
        {
            var childItems = tpUsers.root.childNodes;
            for (var i=0; i<100; i++) <--How do I get number of childNodes??
            {   
                if (childItems[i] != null)
                {
                    childItems[i].setIcon('UserAdd'); <--WANT TO SET ICON
                }
            }
            
        }
        </script>
    /Mikael
  2. #2

    RE: [CLOSED] Change icon on treenode from javascript

    Hi Mikael,

    <script type="text/javascript">
        function setIconCls(node, iconCls) {
            if(node.ui.iconNode){
    
                Ext.fly(node.ui.iconNode).replaceClass(node.attributes.iconCls, iconCls);
    
            }
    
            node.attributes.iconCls = iconCls;
        }
     
        function Test()
        {
            var childItems = tpUsers.root.childNodes;
            for (var i=0; i< childItems.length; i++)
            {   
                setIconCls(childItems[i],'UserAdd');
            }
            
        }
    </script>
  3. #3

    RE: [CLOSED] Change icon on treenode from javascript

    Thank you!!
    Works great!

    /Mikael

Similar Threads

  1. about Treenode.Appendchild's icon
    By helpme in forum 1.x Help
    Replies: 0
    Last Post: Mar 09, 2010, 7:57 AM
  2. Replies: 0
    Last Post: Dec 10, 2009, 11:14 AM
  3. [CLOSED] TreeNode Icon
    By speedstepmem2 in forum 1.x Legacy Premium Help
    Replies: 3
    Last Post: Mar 25, 2009, 12:22 PM
  4. [CLOSED] TreeNode Icon
    By Sharon in forum 1.x Legacy Premium Help
    Replies: 7
    Last Post: Jan 29, 2009, 7:28 AM
  5. Treenode Icon
    By DasPhansom in forum 1.x Help
    Replies: 1
    Last Post: Jan 28, 2009, 11:57 AM

Posting Permissions