Delete Tree table Childern

Hi,
I want to delete tree table parent values. If i delete parent and corresponding childs also getting delted.
I am using Treetable compoenent for this.

Thanks

If you want to delete the parent without deleting the children you must first move the children away from the parent, there is no automated method for this. Either override the method you use for deleting the parent, or make sure to perform the moving before you ever call that. Something like this should do it, I think:

TreeTable treeTable = new TreeTable() {
            @Override
            public boolean removeItem(Object itemId) {
                Collection<?> children = getChildren(itemId);
                for (Object childId : children) {
                    setParent(childId, newParentId);
                }
                return super.removeItem(itemId);
            }
        };

It won’t compile like this, since you’ll still need to figure out where exactly you want to put the items, but that’s a start. You could get the newParentId by asking the parent of the original item, or just use some default value for it, depends on your use case.