Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    TreeGrid folder nodes and leafs css class

    Hi all.
    Can a different css class be set when the node is a leaf and when the node is a folder node (root node) or when is a leaf.

    Example:
    I have this menu, with a dataSource

    final TreeGrid menu = new TreeGrid();

    menu.setStyleName("rootMenu");
    menu.setBaseStyle("nodeSubMenu");
    menu.setBodyStyleName("rootMenu");
    ...

    the result is

    node1 (class = 'nodeSubMenu')
    node2 (class = 'nodeSubMenu')
    node3 (class = 'nodeSubMenu')
    --- node 3.1 (class = 'nodeSubMenu')
    --- node 3.2 (class = 'nodeSubMenu')
    --- node 3.3 (class = 'nodeSubMenu')

    What I want is to set it like this

    node1 (class = 'nodeMenu')
    node2 (class = 'nodeMenu')
    node3 (class = 'nodeMenu')
    --- node 3.1 (class = 'nodeSubMenu')
    --- node 3.2 (class = 'nodeSubMenu')
    --- node 3.3 (class = 'nodeSubMenu')

    Thank you

    #2
    Easiest way would be probably to do something similiar to. If you want to override the entire cell with your own CSS class just replace getCellCSSText with getBaseStyle, there is an example in the showcase.
    Code:
    final TreeGrid treeGrid = new TreeGrid()
    {
      @Override  
      protected String getCellCSSText(ListGridRecord record, int rowNum, int colNum) {  
        MyTreeNode r = (MyTreeNode)record;  
        if (this.getData().isLeaf(r)) {  
          return "font-weight:bold; color:#d64949;";
        }
        else if (this.getData().isFolder(r)) {
          return "font-weight:bold; color:#287fd6;";
        }
        return super.getCellCSSText(record, rowNum, colNum);
      }
    };

    Comment

    Working...
    X