Table: problem with focused row and refreshRenderedCells

Hi,

I need to navigate a table cell by cell to edit single cells pressing ENTER or something. There’s no such component available so I needed something to do that.

I’ve been working in a “spreadsheet table” component. It’s just a vaadin Table with a CellStyleGenerator and a Handler with ShortcutActions to track the current column. Using some css and the Overlay add-on, I managed to get something line a “spreadsheet table”. It’s sluggish and unperformant but saved my day.

Every time I go left or right I’ve to call refreshRenderedCells to apply the styles genereted by CellStyleGenerator. I’ve noted a problem with the focused row when using keboard navigation at the bottom of the table… sometimes focus jumps to the first row although selection is on the last row.

I’ve traced the problem to this code:

com.vaadin.terminal.gwt.client.ui.VScrollTable.java (lines 1232 to 1248)

 
private void focusRowFromBody() {
        if (selectedRowKeys.size() == 1) {
            // try to focus a row currently selected and in viewport
            String selectedRowKey = selectedRowKeys.iterator().next();
            if (selectedRowKey != null) {
                VScrollTableRow renderedRow = getRenderedRowByKey(selectedRowKey);
               [b]
 if (renderedRow == null || !renderedRow.isInViewPort())
[/b]  {
                    setRowFocus(scrollBody.getRowByRowIndex(firstRowInViewPort));
                } else {
                    setRowFocus(renderedRow);
                }
            }
        } else {
            // multiselect mode
            setRowFocus(scrollBody.getRowByRowIndex(firstRowInViewPort));
        }
    }

I don’t know why “renderedRow.isInViewPort()” somtimes returns false although renderedRow actually IS in viewport.

I commented out that and no more focus jumps

 
               [b]
 if (renderedRow == null)
[/b] // || !renderedRow.isInViewPort())

I know my sluggish component is a workarround and won’t last for much longer, but helped to find this kind of bug.

I can’t go deeper with this (lack of time and GWT expertice), so I post this brief to help someone with the same problem with focused row in tables and serveral refreshRenderedCells calls.

I’ve posted the original “sluggish spreadsheet table experiment” code here: https://vaadin.com/forum/-/message_boards/view_message/1231905

Browser: Chrome 20.0.1132.47
Vaadin: 6.7.4
OS: linux 2.6.35.14-106.fc14.x86_64

Regards.