Grid not remove Index on removeAllItems()

Hey there, I have an issue with Vaadin 7.6

I create my grid:

[code]
private Grid grid = new Grid();
grid.addRow(“xxx”,“yyyyy”); // ← Item id = 1
grid.addRow(“xxx”,“yyyyy”); // ← Item id = 2

//Removing rows
grid.getContainerDataSource().removeAllItems();

//Adding rows again
grid.addRow(“xxx”,“yyyyy”); ← Item id = 3 THIS SHOULD be 1
grid.addRow(“xxx”,“yyyyy”); // ← Item id = 4 THIS SHOULD be 2 because I removed all before items.

[/code]but when I try to remove all items to fill it again with new info, it keep index rows…

How can I clear my grid correctly, resetting grid ids to 0?

Thanks a lot.

Have your tried to add items directly to the Container instead of using grid.addRow(…)? Also, if index is important, you should create constructor for your bean where you can give it as parameter.

But if you just need index for the rows, i.e. index not being bound to beans, but just rows, you can render it.

See

https://vaadin.com/directory/component/grid-renderers-collection-for-vaadin7

And RowIndexRenderer.