FXML cellValueFactory for TreeTableColumn
fxml, java-8, javafx-8
Solution
Here is a sample TreeTableView in FXML.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.TreeTableView?>
<?import javafx.scene.control.TreeTableColumn?>
<?import javafx.scene.control.cell.TreeItemPropertyValueFactory?>
<TreeTableView>
<columnResizePolicy>
<TreeTableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
</columnResizePolicy>
<columns>
<TreeTableColumn text="Contract Number">
<cellValueFactory>
<TreeItemPropertyValueFactory property="contractNumber" />
</cellValueFactory>
</TreeTableColumn>
</columns>
</TreeTableView>
See RT-35233.
Problem
I've been trying to build a Tree Table and define the cellValueFactories in FXML. When I try this, I get the following error in the stack trace ``` Exception in thread "JavaFX Application Thread" java.lang.ClassCastException: javafx.scene.control.TreeTableColumn$CellDataFeatures cannot be cast to javafx.scene.control.TableColumn$CellDataFeatures ``` The FXML is written as follows ``` <TreeTableView prefHeight="500.0" prefWidth="600.0" fx:id="customerContractsTable"> <columns> <TreeTableColumn prefWidth="116.0" text="Contract Number"> <cellValueFactory> <PropertyValueFactory property=""/> </cellValueFactory> </TreeTableColumn> </columns> </TreeTableView> ``` I've been trying to find any documentation references on how to do this and am coming up completely empty handed. Any documentation or help would be greatly apperciated.