edvin / tornadofx

Lightweight JavaFX Framework for Kotlin
Apache License 2.0
3.68k stars 272 forks source link

TableView format and Edit #1238

Open SchweinchenFuntik opened 4 years ago

SchweinchenFuntik commented 4 years ago

The cell can only be formatted, or only editable. CellDecorator - does not solve the problem

formatting only:

column(...) {
            makeEditable()
            cellFormat { text = "fomatm" }
}

editing only:

column(...) {
            cellFormat { text = "fomatm" }
            makeEditable()
}

This is because cellFactory is overridden.

makeEditable: cellFactory = TextFieldTableCell.forTableColumn<T, S>(Converter() as Converter<S>)

cellFormat:

fun <S, T> TableColumn<S, T>.cellFormat(scope: Scope = FX.defaultScope, formatter: TableCell<S, T>.(T) -> Unit) {
    properties["tornadofx.cellFormat"] = formatter
    if (properties["tornadofx.cellFormatCapable"] != true)
        cellFactory = Callback { SmartTableCell<S, T>(scope, it) }
}
yamert89 commented 3 years ago

edvin/tornadofx2#35