JavaFX TreeTableView在刷新时重复行

时间:2016-11-04 21:19:45

标签: javafx treetableview

我正在使用树表视图处理JavaFX应用程序,其中列是根据提供的数据生成的。但是,在某些情况下,当更新从后端进入时,一个" ghost row"被建造。这是一个与现有行具有相同值的附加行,但无法选择。如果窗口保持打开的时间足够长,则这些重影行将填充剩余的可见表行(但不会创建滚动条)。

我在Cell Value Factory回调中添加了一些调试逻辑,但数据源仍然表明它只有5个条目,尽管屏幕上可以看到6个或更多。出于某种原因,它似乎只是渲染同一行的另一个副本。

有没有人对可能导致这种情况的原因有任何疑问?

感谢。

编辑:

这是TreeTableCell实现中的UpdateItem方法:

        super.updateItem(item, empty);

        FlowPane flow = new FlowPane();
        if (item != null && !empty && getTreeTableRow() != null)
        {
            Node cellGraphic = item.getGraphic();
            if (cellGraphic != null
                && cellGraphic.getClass().equals(Button.class))
            {
                item.setAlignment(Pos.CENTER);
            }

            flow.getChildren().add(item);
            item.prefWidthProperty().bind(flow.prefWrapLengthProperty());
            flow.prefWrapLengthProperty().bind(
                getTableColumn().widthProperty());
            setGraphic(flow);
            return;
        }

0 个答案:

没有答案
相关问题