Remove Children of TreeTable

I’m trying to remove all children of parent in a TreeTable.
I can get the child ids, however it only removes the first child. (Table repaints and I guess I don’t have that id anymore)

Collection<?> childrenIDs = expgrpgrid.getChildren(target); for (java.util.Iterator<?> i = childrenIDs.iterator(); i.hasNext();){ expgrpgrid.removeItem(i.next()); } Is there a way to do this?

Thank you for the help.

Hi,

I think it has to be with the collection size. Anyway, if you are using Java 8, you can do:

childrenIDs.stream().forEach(expgrpgrid::removeItem);

If not, you have to do something like:

[code]
Object toRemove = childrenIDs.toArray();
int size = toRemove.length;

for (int i = 0; i < size; i++) {
expgrpgrid.removeItem(toRemove[i]
);
}
[/code]Hope that helps!

@Alejandro Thanks a lot, that did the trick.