I have an interesting, but confusing problem, I have a TreeTable that has an ItemClickEvent listener.

When an item is clicked, I log:


And it works perfectly the first time the table is rendered, it logs “1” when the first item is clicked, which is what I would expect.

I have integrated a “Preferences” page where users can remove certain key/value pairs from the TreeTable itself, however something strange is happening when the user returns to the View Mode.

Say the Tree Table starts with 7 items, Item 1 through 7 are selectable, when the user goes to the Preferences page and then returns, suddenly my Items have an Item ID of 8 through 14.

When we return to View Mode, I remove all the components by executing:

if (getComponentCount() == 1)

And I also remove all the Items by using this (tr is the name of my tree table):


It seems to be that the item IDs are recalculated when the table is removed and readded, How can I keep it so that they are the same?

Any advice would be a huge help,

The way I fixed this was:

I created a new table only in the init of the class, I needed to create a new table each time the Mode Change triggered

You could have added property to your tree, instead of relying on the index of the item in the container. .

Thank you for the suggestion and this would have worked!