Search code examples
javascriptextjsextjs4

How do I add a css class to a tree node in Ext4?


I would like to highlight some of the nodes in an Ext.tree.Panel.

In Ext3 I accomplished this by adding a class to the tree node ui object:

// add a class with to highlight the node
myTreeNode.getUI().addClass('highlightclass');

// remove the class to remove the highlighting
myTreeNode.getUI().removeClass('highlightclass');

What is the equivalent in Ext4? I have been able to change the icon by setting the iconCls field of my node model, but I would really like to be able to set a class that allows me to highlight the whole node.


Solution

  • Here is the answer I found to my own question:

    // add a css class to a specific tree node
    myTreePanel.getView().addRowCls(myTreeNode,'highlightclass');
    
    // remove a css class from a specific tree node
    myTreePanel.getView().removeRowCls(myTreeNode,'highlightclass');