javafxjavafx-8treetableviewcolumnspan

How to implement a column headers spanning feature of TreeTableView control?


In the picture below (source) Balance column span Income and Spending columns. I can't found any information of how to achieve this...

Any help appreciated

enter image description here


Solution

  • This feature (nested columns) is documented in the Oracle JavaFX controls tutorials for TableView.

    For example, suppose that the contacts in the address book have two email accounts. Then you need two columns to show the primary and the secondary email addresses. Create two subcolumns, and call the getColumns method on emailCol.

    TableColumn firstEmailCol = new TableColumn("Primary");
    TableColumn secondEmailCol = new TableColumn("Secondary");
    
    emailCol.getColumns().addAll(firstEmailCol, secondEmailCol);
    

    nested columns

    Read the nested columns javadoc (TableColumnBase.getColumns) for more information.