iari
10/27/2019, 7:42 AMBogdan
10/27/2019, 7:46 AMBogdan
10/27/2019, 7:47 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>()
}iari
10/27/2019, 8:09 AMiari
10/27/2019, 8:11 AMclass LabelsDocumentDataModel : ItemViewModel<LabelsDocumentData>() {
// ... other stuff
val data = bind(LabelsDocumentData::data)
}iari
10/27/2019, 8:13 AMiari
10/27/2019, 8:14 AMBogdan
10/27/2019, 8:25 AMdatagrid(data) - does not work ?Bogdan
10/27/2019, 8:36 AMcellFragment<LabelContentFragment>() - you have your own fragment, you need to make sure that it can resizeBogdan
10/27/2019, 8:37 AMupdateItems- called when updating your listiari
10/27/2019, 8:40 AMiari
10/27/2019, 8:41 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 AMiari
10/27/2019, 8:44 AMiari
10/27/2019, 8:44 AMiari
10/27/2019, 8:44 AMiari
10/27/2019, 8:44 AMiari
10/27/2019, 8:45 AMiari
10/27/2019, 8:45 AMiari
10/27/2019, 8:45 AMBogdan
10/27/2019, 8:47 AMiari
10/27/2019, 8:47 AMiari
10/27/2019, 8:47 AMiari
10/27/2019, 8:59 AMiari
10/27/2019, 9:01 AMiari
10/27/2019, 9:01 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)
}
}
}iari
10/27/2019, 9:02 AMBogdan
10/27/2019, 9:11 AMBogdan
10/27/2019, 9:15 AMBogdan
10/27/2019, 9:52 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 }
                }
            }
        }
    }
}Bogdan
10/27/2019, 9:54 AMmaxCellsInRowProperty - 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.Bogdan
10/27/2019, 10:07 AMBogdan
10/27/2019, 10:19 AMBogdan
10/27/2019, 10:20 AMminWidth = width +- widthItem +- spaceItems