SpreadsheetView: incorrect cell layout after toggling column/row visibility [Update: ExampleCode]

Issue #825 new
Thomas Faltermeier
created an issue

I created a spreadsheet view with cells containing some text and an image in the graphics property.

When applying my custom filtering which toggles the visibility of rows and columns using the showColumn/hideColumn and showRow/hideRow methods of the SpreadsheetView itself, the text and the graphic of the cell are above each other. The layouting seems to break in general since the cell should be center left aligned and not top left.

This doesn't happen every time but most of the times I toggle the rows.

Comments (9)

  1. DuncanChang

    I have a similar issue. During the experiment(trying fix the problem) I notice one thing:

    If vertical and horizontal scrollbar shows before and after spreadsheet view state mutate, this "Incorrect cell layout" behavior won't occur.

    e.g. run main class in SpreadsheetTest, shrink main stage(window) until you can see three columns and five rows in viewport, repeating press 'Toggle' button would not cause "incorrect cell layout".

    It seems spreadsheet view render(and reuse) a constant amount of cells while model(grid) is mutating, there is no "incorrect cell layout".

  2. Thomas Faltermeier reporter

    I took a look at the code. Unfortunately our corporate policy doesn't allow for me to contribute... :(

    But I'm pretty sure the problem is in the CellView class in the updateItem method:

    public void updateItem(final SpreadsheetCell item, boolean empty) {
            final boolean emptyRow = getTableView().getItems().size() < getIndex() + 1;
            /**
             * don't call super.updateItem() because it will trigger cancelEdit() if
             * the cell is being edited. It causes calling commitEdit() ALWAYS call
             * cancelEdit as well which is undesired.
             * 
             */
            if (!isEditing()) {
                super.updateItem(item, empty && emptyRow);
            }
            if (empty && isSelected()) {
                updateSelected(false);
            }
            if (empty && emptyRow) {
                textProperty().unbind();
                setText(null);
                // do not nullify graphic here. Let the TableRow to control cell
                // dislay
                // setGraphic(null);
                setContentDisplay(null);
            } else if (!isEditing() && item != null) {
                show(item);
                if (item.getGraphic() == null) {
                    setGraphic(null);
                }
            }
        }
    

    setContentDisplay(null); in combinations with a non null grafic seems to be breaking the layout. I guess something breaks with java here and the layouting fails because the content display is null but a graphic is available. Once I remove the line or simply set the content display to text only(to hide the grafic) and create my own ControlsFx the layouting issue goes away.

  3. Log in to comment