Change container in grid

It’s possible to change grid container on the fly? When I’m trying to do that, I have following exception:

Caused by: java.lang.NullPointerException: null
    at$GridValueChangeListener.removeListener( ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at$ActiveRowHandler.removeValueChangeListeners( ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at$ActiveRowHandler.access$1300( ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at com.vaadin.server.AbstractClientConnector.removeExtension( ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at com.vaadin.ui.Grid.internalSetContainerDataSource( ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

    at com.vaadin.ui.Grid.setContainerDataSource( ~[vaadin-server-7.4.0.rc1.jar:7.4.0.rc1]

Seeing your trace, it seems that you are providing a “null” instantiated object.

What are you aiming to do? Update the data of the grid?

I have exactly the same Problem. I want to update the content of the Grid by calling setContainerDataSource() with an own created Container.Indexed. Calling the first time everything works as expected. But the second time the mentioned Exception (same stacktrace) is thrown.

I’m using Grid component to display list of files attached with selected item.
When user changes item, new container is created and used as datasource for a grid…

@karpfen Unfortunately, official documentation doesn’t mention about above issue or limitation. I think this is bug.

Ok. There is a fix here:

Unfortunately, it will be included in next release.

Thanks to both @Lukasz and @karpfen. I think my problem is similar… When I delete a row, the changes on the grid are not shown until I refresh the page. Addition of row elements are made using a Window (a modal window), and after adding one, results are not shown until I refresh the page…

In my case, I can confirm that the workaround solution stated in
solved the reported issue.

The mentioned solution was simply to clear the container (.removeAllItems()), just before setting a new one in the grid.

And was helpful for me :slight_smile: Ty!