Gargoolgala
New Member
- Joined
- Sep 1, 2016
- Messages
- 6
Hi - I have a treeview that can have multiple parent nodes with children beneath. I need to be able to have the parent or parents parent and so on checked if a child anywhere down the tree is checked.
parent
- child1
parent2
- child1
- child2
- subchild1
- subchild2
if any of the children are checked I need the parent checked - so if child1, child2 or subchild1 is checked then I need parent2 and child2 subchild1 to all be checked. If I uncheck subchild1 and no other subchildren are checked then I want child2 to be unchecked and parent 2 to also be unchecked but only if no other children of parent2 are checked. So if I uncheck subchild1 but child1 is checked then I need parent2 to stay checked but child2 to be unchecked.
I think I need to do some recursive magic but cannot get my head around it. Most posts I have found seem to focus on checking from the top down but I think I need to look from the bottom up - sooo confused.
Any assistance is appreciated.
parent
- child1
parent2
- child1
- child2
- subchild1
- subchild2
if any of the children are checked I need the parent checked - so if child1, child2 or subchild1 is checked then I need parent2 and child2 subchild1 to all be checked. If I uncheck subchild1 and no other subchildren are checked then I want child2 to be unchecked and parent 2 to also be unchecked but only if no other children of parent2 are checked. So if I uncheck subchild1 but child1 is checked then I need parent2 to stay checked but child2 to be unchecked.
I think I need to do some recursive magic but cannot get my head around it. Most posts I have found seem to focus on checking from the top down but I think I need to look from the bottom up - sooo confused.
Any assistance is appreciated.