1

The question says it all. When the tree is presented vertically the root node is not displayed. Setting rendered to false does not do it.

Verticon
  • 2,419
  • 16
  • 34

1 Answers1

0

Well, as usual, CSS comes to the rescue. A simple attempt with a browser developer tool on the PrimeFaces showcase (I don't use the horizontal tree myself), with putting a css display:none directly on the first html element with class of ui-treenode node html makes it disappear, including the first line.

enter image description here

But there are childnodes in there... Putting a display:none on the first html node with a class of ui-tree-content makes the content of the first node disappear and keep the line in tact and the rest of the tree still functions fine.

enter image description here

So we already effectivly know it can be done...

The only thing needed then is a 'full' selector. The folling hides ALL nodes, not what you want.

.ui-tree  .ui-treenode > .ui-treenode-content {
    display: none;
}

enter image description here

So the selector should be improved. Adding all intermediate elements to the first node is a solution

.ui-tree > table > tbody > tr > .ui-treenode > .ui-treenode-content {
    display: none;
}

enter image description here

(replacing the table, tbody and tr with a * would work too). But a more advanced solution where you actually select the first node with a class .ui-tree-nodeis

.ui-tree .ui-treenode:first-child > .ui-treenode-content {
    display: none;
}

And if you e.g. only want it on a specific horizontal tree, add a class to that tree (e.g. no-root) and use it in the selector as well

.no-root.ui-tree .ui-treenode:first-child > .ui-treenode-content {
    display: none;
}

What I effectively did here was (to try to) apply basic css knowledge and it provided a solution. Remember, client side it is (99.5% of the time) all html, css and javascript!!!

See also: See also:

Kukeltje
  • 12,223
  • 4
  • 24
  • 47
  • I found that ".ui-tree .ui-treenode:first-child { display: none; }" hides the root node and any leaf nodes which have no siblings. What worked for me is "td[data-nodetype="default"] { display: none; }" and setting the type of all of my nodes, other than the root node, to a custom value (ex. "visible") – Verticon May 18 '18 at 17:47