Views
4 months ago

tornadofx-guide

5. Data Controls There

5. Data Controls There are a few configurability options, like "expand on double-click" behaviors and accessing the expanderColumn (the column with the "+" button) to drive a padding (Figure 5.6). override val root = tableview(regions) { column("ID",Region::id) column("Name", Region::name) column("Country", Region::country) rowExpander(expandOnDoubleClick = true) { paddingLeft = expanderColumn.width tableview(it.branches) { column("ID",Branch::id) column("Facility Code",Branch::facilityCode) column("City",Branch::city) column("State/Province",Branch::stateProvince) } } } Figure 5.6 60

5. Data Controls The rowExpander() function does not have to return a TableView but any kind of Node , including Forms and other simple or complex controls. Accessing the Expander Column You might want to manipulate or call functions on the actual expander column. If you activate expand on double click, you might not want to show the expander column in the table at all. First we need a reference to the expander: val expander = rowExpander(true) { ... } If you want to hide the expander column, just call expander.isVisible = false . You can also programmatically toggle the expanded state of any column by calling expander.toggleExpanded(rowIndex) . TreeView The TreeView contains elements where each element may contain child elements. Typically arrows allow you to expand a parent element to see its children. For instance, we can nest employees under department names 61

GUIDE
Guide
GUIDE
Guide
Guide
Guide
GUIDE
GUIDE
Guide
GUIDE
GUIDE
GUIDE