Search code examples
javacssvaadintreetable

How to hide expand/collapse icon in vaadin treetable?


Good day everyone! I have a treetable below:

treetable

and I have tried to set the itemcaption to null using this code but it doesn't work:

public void uncollapseTable(){
    for (Object itemId: tblFinalGrade.getItemIds()){
        tblFinalGrade.setCollapsed(itemId, false);
        unHideChildren(itemId);
        tblFinalGrade.setItemCaption(itemId, null);
    }
}
public void unHideChildren(Object itemId){
    if(tblFinalGrade.hasChildren(itemId)){
        for(Object id : tblFinalGrade.getChildren(itemId)){
            tblFinalGrade.setCollapsed(id, false);
            unHideChildren(id);
            tblFinalGrade.setItemCaption(id, null);
        }
    }           
}

Is it possible to remove/hide the expand/collapse icons without css? If not, how do I hide it using css? Thanks!


Solution

  • Thanks @Kukis for the idea. Displaying nothing will remove the icons and the format itself, so I made it invisible instead. I added:

    .v-treetable-treespacer{
        visibility: hidden;
    }
    

    to my theme and recompiled it. So now it looks like this:

    Tree table without icon