Vaadin8.1+ grid.Select() is not reflected on UI

Wondering if anyone else has had this issue. No matter what I seem to do a programatic select of an item does not seem to result in the correspondent check of the box on the UI in the case of multi-select or the select of the Row in the case of single mode.

  1. The items appear to have been selected.
  2. When I inspect the page…it appears that the checkbox value is “on”.
  3. The style does not seem to change to “v-grid-row-selected”

I have tried to call a MarkDirty and well as column resize to force redraw but nothing seems to work. I have tried it on both hidden and displayed grids. Same results.

Does anyone have any ideas?

Thanks

Do you have an example of the code where the problem occurs? I could not reproduce the problem in a minimal test UI.



See the full sample on vaadinfiddle.com

Could it be that the value you are trying to select is not in the grid?

Yeah…it basically not working anywhere…for example this is one where I am trying every trick to get it to register the selection. So I reselect the items. I change the selection mode. I Mark as dirty. Still no check change in style to selected.

[code]
public void setGrid(Grid select) {
selectGrid = select;
selectionArea.removeAllComponents();
selectionArea.addComponent(selectGrid);

    Set<T> getsel = selectGrid.getSelectedItems();
    
    GridSelectionModel sm = selectGrid.getSelectionModel();
    if (sm instanceof SingleSelectionModel) {
        selectGrid.setSelectionMode(SelectionMode.MULTI);
        selectGrid.setSelectionMode(SelectionMode.SINGLE);
    } else {
        selectGrid.setSelectionMode(SelectionMode.SINGLE);
        selectGrid.setSelectionMode(SelectionMode.MULTI);            
    }
    
    for(Object item: getsel) {
        selectGrid.select(item);
    }
    
    selectGrid.markAsDirtyRecursive();
}

[/code]One thing I just noticed which is odd…if I select an item in the open grid with the above code, close the window (in this case a pop up). Then reopen it…meaning it runs through the above code completely replacing the component, the item I selected previously is still highlighted. To be clear…I select 10 items programatically…nothing shows when I get to the grid. I then select one of the items manually. Close the window. I reopen it which runs the above code. The 10 selected items that were not showing up are still not showing up, but with the one item which was selected manually is. FYI…same grid in this case. Its sits unused on another view and is just inserted into the pop up when needed.

oh…and item definitely on grid…selections work fine. If I ignore the fact that I cant see them they function as they are supposed to–at least server side.

Thanks.

If it’s just the problem that you cannot see the selected item, you can use

selectGrid.scrollTo()

A) You cant ‘just’ use scrollTo since it (in vaadin 8) take a int row, where as select take a T item and there don’t seem to be a simple way to get the row of an item
B) I have the same problem as originally posted, and it is not related to scrolling. For some views select work as expected for others it get ignored