Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FXML cellValueFactory for TreeTableColumn

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.

like image 307
LinkXXI Avatar asked Feb 12 '23 13:02

LinkXXI


1 Answers

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.

like image 183
Christopher Towner Avatar answered Apr 06 '23 00:04

Christopher Towner