How to change background color of a tree node after clicking on it.

  1. #1

    How to change background color of a tree node after clicking on it.



    I am having a treepanel and loading tree nodes through loader. While rendering tree nodes, I am assigning default style to each and every tree nodes. Now, I want to change the background color dynamically of another tree nodes on click on a treenode.

    How can I do that?

    Please help.
  2. #2

    RE: How to change background color of a tree node after clicking on it.

    Add css to cls property.

    myNode.Cls = "NodeCss2"
    where NodeCss:




    /* entire node */
    .NodeCss1 {background-color: yellow;}


    /* only text */
    .NodeCss2 a span{background-color: yellow;}

    -----------------
    Don't work. I have not noticed this: "...after clicking on it.". Sorry
  3. #3

    RE: How to change background color of a tree node after clicking on it.



    So works :)

    JavaScript function example:

    ...
    
    function nodeSelected(node) {            
     var pnode = node.parentNode;
     var nnode = new Ext.tree.AsyncTreeNode(
     {
      text: node.text,
      id: node.id,
      leaf: node.leaf,
      allowDrop: node.attributes.allowDrop,
      icon: node.attributes.icon,
      cls: 'NodeCss2',
      qtip: node.attributes.qtip,
      YourAttr: node.attributes.YourAttr
     });
    
    
     pnode.replaceChild(nnode, node);           
    }
    
    ...
  4. #4

    what are you passing node as parameter?

    what are you passing node as parameter?

Similar Threads

  1. How to Background color to the cell in Tree grid
    By rajputamit in forum 1.x Help
    Replies: 2
    Last Post: May 06, 2012, 4:16 PM
  2. Replies: 2
    Last Post: Dec 29, 2011, 2:11 AM
  3. Dynamically change textfield background color
    By VALUELAB in forum 1.x Help
    Replies: 0
    Last Post: Mar 04, 2011, 4:50 PM
  4. Replies: 12
    Last Post: Jun 17, 2009, 12:07 PM
  5. Change Tab background color or background image
    By georgelanes in forum 1.x Help
    Replies: 0
    Last Post: Nov 06, 2008, 3:55 PM

Posting Permissions