Accessing nested properties Let's assume our `Per...
# tornadofx
e
#### Accessing nested properties Let's assume our
Person
object has a
parent
property which is also of of type
Person
. To create a column for the parent name, we have several options. Our first attempt is simply extracting the name property manually:
Copy code
column<Person, String>("Parent name", { it.value.parentProperty.value.nameProperty })
While this works, it has one major drawback. If the parent changes, the list won't be updated. We can partially remedy this by defining the value for the property as the parent itself, and formatting it's name:
Copy code
column("Parent name", Person::parentProperty).cellFormat {
    textProperty().bind(it.parentProperty.value.nameProperty)
}
It might still not update right away, even though it would eventually become consistent as the TableView refreshes. To create a binding that would reflect a change to the parent property immediately, consider using a select binding:
Copy code
column<Person, String>("Parent name", { it.value.parentProperty.select(Person::nameProperty) })