设置 cellFormat 时 makeeditable 不起作用

makeeditable doesnt work when setting cellFormat

我有一个table如下:

with(myTable)
{
    enableCellEditing()
    columnResizePolicy = SmartResize.POLICY
    isEditable = true
    column("Issue Date", TradeEntity::issueDate).makeEditable().cellFormat { tc ->
        style { if (tc.dayOfMonth==10) backgroundColor += Color.ORANGE }
        text = tc.toString()
    }

我不能制作这个 editable 并且有风格。 要么是我有风格,要么是editable... 有帮助吗?

EDIT 解决了,至少在Java,我猜都是因为我没有在Kotlin

中调用super.updateItem(it,empty)

好的,我不知道为什么没有答案,但由于 2013 Oracle 教程 https://docs.oracle.com/javafx/2/ui_controls/table-view.htm,and 到 Intellij autocompetion,我设法在 Java 中做到了。 现在我必须在 Kotlin

中这样做
Callback<TableColumn<Person, String>, TableCell<Person, String>> cb = new Callback<TableColumn<Person, String>, TableCell<Person, String>>()
{
    @Override
    public TableCell<Person, String> call(TableColumn<Person, String> param) {


        TextFieldTableCell res = new TextFieldTableCell<Person, String>(new DefaultStringConverter()) {
            @Override
            public void updateItem(String it, boolean empty) {
                super.updateItem(it, empty);
                if (it == null || empty) {
                    setText(null);
                    setStyle("");
                } else {
                    setText(it);
                    setStyle("-fx-background-color: red");

                }

            }
        };
        System.out.println("callback called");
        return res;
    }
};

yourColumn.setCellFactory(cb);

cellFormat 将替换您调用 makeEditable() 时安装的 CellFactory,因此它们相互直接竞争。出于这个原因,TornadoFX 提供 cellDecorator,它保留现有的 CellFactory:

column("First Name", Customer::firstNameProperty) {
    makeEditable()
    cellDecorator {
        style {
            fontWeight = FontWeight.BOLD
        }
    }
}