Adding items directly to a table's container doesn't work

Hi,
Since the table comes by default with an IndexedContainer, I am trying to add an item at a certain position using addItemAt(). The problem is that for some reason, any operation performed on the container directly instead of the table doesn’t work. Here there is a simple example:

[code]
Table testTable = new Table();
Container container = testTable.getContainerDataSource();

testTable.addContainerProperty(“First Name”, String.class, null);
testTable.addContainerProperty(“Last Name”, String.class, null);
container.addContainerProperty(“Location”, String.class, null)
[/code]The columns “First name” and “Last Name” are added to the table, but the column “Location” it is not. What am I missing?

Hi,

If you take a look at the addContainerProperty in Table, you will see that it adds the property AND shows the column in the table. Container does not :wink:
So your column is indeed in the container but table is not displaying it.

Here is the function signature :
/**
* Adds a new property to the table and show it as a visible column.
*
* @param propertyId
* the Id of the proprty.
* @param type
* the class of the property.
* @param defaultValue
* the default value given for all existing items.
* @see com.vaadin.data.Container#addContainerProperty(Object, Class,
* Object)
*/

@Override
public boolean addContainerProperty(Object propertyId, Class<?> type,
        Object defaultValue)

Regards

Oh, that was stupid, I should have checked better.
So I guess I have to add it to the visibleColumns afterwards if I want to use the container method.

Thanks for the help!

Incase you use BeanContainer as your ContainerDatasource, you can add items directory to the container I guess.