I think I want to originally show the entire tree for the oldest person (no ParentID).
You will have to pick a person as your base node. If you pick all IDs with no parents you will get a lot of trees. So if you are tracking your tree back X generations, you are not tracking your spouse back X generations. You may not have anything on here side except she is a parent to your kids.
Then have the ability to select a person from the tree and Clear the tree and re-Initiate the tree and then show just the descendants from that person.
That should be easy to do since the recursive code is setup to provide a starting node. Normally it is like you said where the base nodes are everything without a parent, but in this case you can pass in the base node. It is one of the load parameters
Hopefully there is a way to show spouse for any family entry, so that person is clickable for navigation.
If I was going to show spouse. I would first load the tree recursively. Then loop the nodes and check for a spouse. And add the spouse in
So if I select Male Parent from the table, it should show(and some how include the Spouse in a same level node?):
-Male Parent
----Male Child
----Female Child
-Female Parent(?)
Where does it make sense to add the female parent? What you show would be an easy solution, if that works for you. Is it OK not to double up the children under the non biological Parent? Since you are spanning from the top down the biological parent is the parent related to the top node. The other options with a little bit of code could be
Biological Parent / Spouse Parent
--- Child
---Child 2
Currently the code is written so that when you click or select a node, the record PK and table are returned. That way you associate a node with a record. In this case you could add code to pop up a small form says which one do you want Mother or Father. The PK is stored in the Node Key. You would have to modify the node create event to make the key something like PER123;PER456. And you could do this. This would be some work but doable.
For this application, there will be a split page form with the tree on the left and a full Member Detail on the right, so the tree will always "root" at one person, but also provide navigation.
That is pretty standard how I use the tree
Since its just the descendants, I'll have to put a click event on the Parents section of the Member Detail to allow to ascend up the tree
This can be done. If you clicked on a single person. Then you should create the parent node/s as the base node
The problem I am seeing is that a child will have two parentIDs (in most cases). Depending on who is selected in the tree, I can show descendants down the tree using just one of the queries (Spouse1 or Spouse2), if the spouse1s all relate to the person selected and spouse2s all relate to the spouse of the person selected. I didnt want to do Father and Mother for Spouse1 and Spouse2 to be more flexible, but will this create an issue where one family has spouse1 the male and spouse2 the female, and then another family is spouse 2 the male and spouse1 the female?
This is really the dilemma on how you want the tree to work and how you handle spouses. If in your person table you relate persons to their biological family and spouses are identified only in the family table it should not matter. If I am doing my tree I relate myself to my parents, but I do not relate my wife to her in laws. Now this could get really hard if you decide to combine your family tree and her family tree. I think you could do it, but would require an additional field to say which tree you are spanning. Because now you have a network not a tree.
By far the easiest solution is to put the non “biological” spouse as a node at the same level as the “biological” spouse and just put the children under the biological spouse. If I get some time I can try to demo the more complex approach with a combined Parent node.
I'd need to union the queries at that point? I am going to try to implement this further and will provide more detail
7. If you want to simply put the spouse in as a node at the same level then no. Simply build the tree for the biological children off of the base node. Then once built, loop the nodes collection. Check each node for a spouse. If a spouse exists then add. However, since the children are not under both parents the issue could arise where you have a first wife and second wife or the spouse is not the parent of all the kids.
In this case you may have to add in the spouse node and then check for children under that spouse. Again since this is not recursive it should not be that hard.
In other words Grandfather Jim Married GrandMom Mary. Mary brought three kids to the marriage.
Other issue I see is when I select a person in the tree, the node I get is the ID, but in the Init function, it uses the ParentStartID, so if I put the SelectedNode in that Init statement, it pulls just the children without showing the person selected. If I do SelectedNode.parent.Key, then it will show the person selected, but also any siblings that have that that same parentID. Not sure that is a bad thing, but not sure if I can just show selected
Your best solution would be to add the parent ID then delete (if you want) any brothers and sisters of the base node.
Bottom line you may not want to try to do it all in a single load of the tree. You may find easier solutions to load then add, modify, and delete nodes. Again this can be a lot easier since it is not recursive. You can loop the nodes. Get the PK and modify spouses, children, parents and the node itself. The hard part is synching the node keys with a primary key so the node and the record are "synched".