设置格式时单元格值不再可编辑

cell value is no more editable when setting format

当我使用此处定义的 cellFormat 功能时 https://github.com/edvin/tornadofx-guide/blob/master/part1/5.%20Data%20Controls.md 我在 table 中的单元格停止显示其值,并且不再是 editable。 我的 table 看起来像:

        with(tradeTable)
        {
            enableCellEditing()
            columnResizePolicy = SmartResize.POLICY
            isEditable = true
            column("Id", TradeEntity::id)
            column("Issue Date", TradeEntity::issueDate).makeEditable().cellFormat {
                style {
//                    if (it.dayOfMonth - LocalDate.now().dayOfMonth<=2 ) {
//                        backgroundColor+=c("#FFA500")
//                        textFill = Color.WHITE
//                    }
                }

            } ... more columns...

如您所见,即使我明确指定它,makeEditable()也没有效果,即使样式实际上被注释掉了。 如何在不牺牲编辑功能的情况下为单元格(或实际上是行?)制作自定义样式?

我见过的所有示例都在cellFormat中明确指定了text属性,因此您应该将代码修改为:

column("Issue Date", TradeEntity::issueDate).makeEditable().cellFormat {
      style {
          // whatever 
      }
      text = it.toString() //possible transformations?
}

cellFormat 要求您分配给单元格的 textgraphic 属性,否则将不显示任何内容。由于 cellFormat 安装了它自己的 CellFactory,它与 makeEditable() 直接竞争。如果您调用 makeEditable(),您可以使用 cellDecorator 而不是 cellFormat 来进一步自定义您的单元格。