Container for this Grid is not a default container from Grid() constructor

Hello,

I get the following failure:

Caused by: java.lang.IllegalStateException: Container for this Grid is not a default container from Grid() constructor
at com.vaadin.ui.Grid.addColumnProperty(Grid.java:3408)
at com.vaadin.ui.Grid.addColumn(Grid.java:3401)

when using:

/**
 * To allow access to invisible rows so they
 * can be updated even if they do not pass the filter.
 */
private static class Indexed_container
    extends IndexedContainer
{
    @Override
    public Item getUnfilteredItem(final Object a_item_id)
    {
        return super.getUnfilteredItem(a_item_id);
    }
}

final Grid grid_ = new Grid(new Indexed_container());
grid_.addColumn("Column Name", My_class.class); 

Is the code incorrect or this not permitted (and will never be permitted) ?

Regards,
Martin.

I forgot to mention that I am using VAADIN v7.4.2.

From BoV:
“Grid has no generated columns. Instead, the container data source can be wrapped around a GeneratedPropertyContainer.”
So, as I understand, you can’t use IndexedContainer to dynamically add columns. You should include IndexedContainer in GeneratedPropertyContainer, then add columns to GeneratedPropertyContainer and then add GeneratedPropertyContainer as Grid’s data source.

The addColumn method in Grid cannot add columns that do not already exist in the container, unless it’s the “default” container initialized by the default constructor. You must add columns to the container instead.

Johannes,

thank you very much. I followed your instructions and it worked correctly.

Thanks,
Martin.

how can i add columns to container?
or how can i initialize container as the default constructor.?