Important Notice - Forums is archived
To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.
Vaadin Grid: There are 0 visible columns error.
Hi
I'm trying to add multiple rows at a time. Trying to modify the Book example.
public void features(VerticalLayout layout) {
IndexedContainer container = new IndexedContainer();
container.addContainerProperty("firstname", String.class, null);
container.addContainerProperty("lastname", String.class, null);
container.addContainerProperty("born", Integer.class, null);
container.addContainerProperty("died", Integer.class, null);
Object pids = container.getContainerPropertyIds().toArray();
// Add some data rows
Object data = new Object {
{"Nicolaus", "Copernicus", 1473, 1543},
{"Galileo", "Galilei", 1564, 1642},
{"Johannes", "Kepler", 1571, 1630},
{"Tycho", "Brahe", 1546, 1601},
{"Giordano", "Bruno", 1548, 1600},
{"Christiaan", "Huygens", 1629, 1695}};
for (Object row: data) {
Object itemId = container.addItem();
for (int i=0; i<pids.length; i++)
container.getContainerProperty(itemId, pids).setValue(row);}
//My Change!
//If I add rows like this I get There are 0 visible columns, but 4 cell values were provided. Error!
for (int i = 0; i < 10000; i++) {
grid.addRow("Nicolaus", "Copernicus", 1473, 1543);
}
Thanks,
Hi,
you're adding rows to the Grid instead of the Container. You should add the container to the Grid and add the Items (=rows) to the Container. If you want to add rows directly to the Grid, define columns in the Grid instead.
-Olli