iari
10/27/2019, 7:42 AMBogdan
10/27/2019, 7:46 AMdatagrid(observableList)
iari
10/27/2019, 8:04 AMBogdan
10/27/2019, 8:06 AMiari
10/27/2019, 8:08 AMdatagrid<LabelContent> {
hgrow = Priority.ALWAYS
maxCellsInRowProperty.bind(data.columns)
data.columns.onChange {
DataGridSkin::class.java.getDeclaredMethod("updateItems").apply {
isAccessible = true
invoke(this@datagrid.skin)
}
}
itemsProperty.bind(data.data)
cellFragment<LabelContentFragment>()
}
class LabelsDocumentDataModel : ItemViewModel<LabelsDocumentData>() {
// ... other stuff
val data = bind(LabelsDocumentData::data)
}
Bogdan
10/27/2019, 8:25 AMdatagrid(data)
- does not work ?cellFragment<LabelContentFragment>()
- you have your own fragment, you need to make sure that it can resizeupdateItems
- called when updating your listiari
10/27/2019, 8:40 AMBogdan
10/27/2019, 8:43 AMaxCellsInRowProperty.bind(data.columns)
data.columns.onChange {
DataGridSkin::class.java.getDeclaredMethod("updateItems").apply {
isAccessible = true
invoke(this@datagrid.skin)
}
}
- meaning then in this code? it's a reflectioniari
10/27/2019, 8:43 AMBogdan
10/27/2019, 8:47 AMiari
10/27/2019, 8:47 AMclass Test : View("Test") {
val myData = observableListOf<String>()
val maxCols = SimpleIntegerProperty(3)
override val root = vbox {
hbox {
button("add") {
action {
myData.add("str-${myData.size}")
}
}
spinner(1, 10, 3, 1, true, maxCols)
}
datagrid<String>(myData) {
maxCellsInRowProperty.bind(maxCols)
}
}
}
Bogdan
10/27/2019, 9:11 AMclass Test2 : View("Test") {
val myData = observableListOf<String>()
val maxCols = intProperty(2)
override val root = vbox {
hbox {
button("add") {
action {
myData.add("str-${myData.size}")
}
}
spinner(1, 10, 3, 1, true, maxCols)
}
datagrid<String>(myData) {
maxCellsInRowProperty.bind(maxCols)
maxCols.addListener { _, old, new ->
val oldValue = old.toInt()
val newValue = new.toInt()
println("$height:$width")
if (oldValue < newValue) {
minWidth = width + 100.0 // not work scroll
// currentStage?.let { it.width += 100.0 }
} else if (oldValue > newValue) {
minWidth = width - 100.0 // not work scroll
// currentStage?.let { it.width -= 100.0 }
}
}
}
}
}
maxCellsInRowProperty
- only sets the maximum possible amount, but does not determine the current, for this you need to change the size itselfiari
10/27/2019, 10:02 AMBogdan
10/27/2019, 10:06 AMdatagrid
. I conducted an experiment and found out that even if you increase maxCellsInRowProperty
and expand the window, the elements cannot be selected. This behavior resembles FlowPane
.minWidth = width +- widthItem +- spaceItems