0

I'm working with a JavaFX TreeTableView containing items of type BillingTableRow. I want the columns to be styled based on a value given by a method getType() in BillingTableRow, but I can't seem to access it from inside the callback that I'm trying to set up. Here is my code:

Callback<TreeTableColumn<BillingTableRow, Double>, TreeTableCell<BillingTableRow, Double>> eveningCallback = new Callback<TreeTableColumn<BillingTableRow, Double>, TreeTableCell<BillingTableRow, Double>>() {
        @Override
        public TreeTableCell<BillingTableRow, Double> call(TreeTableColumn<BillingTableRow, Double> p) {
            return new EditableTreeTableDoubleCell() {
                @Override
                public void updateItem(Double item, boolean empty) {
                    super.updateItem(item, empty);

                    BillingTableRow row = (...)// Get attached BillingTableRow for current tree table row.
                    if (row.getType() == 0) {
                        setText(null);
                    }

                }
            };
        }
    };
    eveningColumn.setCellFactory(eveningCallback);

What should I replace (...) with in order to get it to work?

1 Answers1

2

Use

BillingTableRow row = getTreeTableRow().getItem();

Both TableCell and TreeTableCell define a tableRow property that gives the cell displaying the entire row to which the current cell belongs. For a TreeTableCell<S,T>, getTreeTableRow() will return a TreeTableRow<S> which is a subclass of Cell<S>. This means it has a getItem() method whose return type is S, i.e. the item that represents the data for the entire row.

James_D
  • 201,275
  • 16
  • 291
  • 322