I am trying to find the right way to build a hierarchical grid. I will present a case much like what I want, showing all of the cases that my application will need.
In the above view, you can see that there are multiple types of data.
The first is the root node - I show two, titled 'Checklist One' and 'Checklist Two'. As you can see, one is complex, while the other is simple.There will be multiple root nodes that all have multiple questions of varying depth that descend from them. I would like to have the ability to view multiple root nodes and all of the resulting questions, but my requirements only ask to see one at a time.
The next levels are characterized by questions that lead to further questions, or ending questions. You can see that each has a different structure.
Some questions may have further child questions. These questions have free-form answers possible and nothing else. These will never be at the root of the tree, but a given answer may terminate as a leaf. Furthermore, they can have no limit to how often one question descends from another. If you look at Checklist One, you can see a case where the non-root/non-leaf nodes go three levels deep before terminating in the end (leaf) questions, and how two free-form answers end with no further child questions. I would like to have as many levels of depth as possible, but it is unlikely that I will see more than three levels, as I have illustrated above.
Some questions never have child questions. These questions have a list of possible answers (yes, no, equally, both, cake, pie) and there is also an associated 'score'. This is entirely different from the questions above, so they will need to display their data differently. These questions are leaves in the tree. They will never be the root, but they may be connected to the root directly. (Look at Checklist Two for an example where there is a root node - Checklist Two - and two leaf nodes - the coffee question and the tea question. There are no middle nodes there.)
In my database, the root nodes are held in one table, the leaf questions are held in another, and the non-root/non-leaf questions are held in a looping parent-child structure in a third set of tables. Of course, I will be presenting the grid(s) with data via LINQ so the table structures themselves are not important, as I can just create anonymous objects to carry my data.
How should I build this grid? It seems that there is both self-referencing and multiple detail tables, but I haven't found a way to mix the two correctly in a RadGrid.
Checklist One
|
+- What is your age?
|
+- Age : Under 40
| |
| +- Do you like cake? (Available answers : Yes, no) (Score: 3)
| |
| +- Do you like pie? (Available answers : Yes, no) (Score: 3)
| |
| +- Do you like cake more than pie? (Available answers : Yes, no, equally) (Score: 2)
|
+- Age : At or Over 40
|
+- Do you like cake? (Available answers : Yes, no) (Score: 3)
|
+- Do you like pie? (Available answers : Yes, no) (Score: 3)
|
+- Do you like cake more than pie? (Available answers : Yes, no, equally) (Score: 2)
|
+- Do you diet often?
|
+- Answer : More or less, yes.
| |
| +- Does your love of cake and/or pie interfere with your dieting? (Available answers : Yes, no) (Score: 1)
| |
| +- Do you wish you loved cake and/or pie less?
| |
| +- Answer : It would help, yes.
| | |
| | +- Would you rather love cake or pie less? (Available answers : Cake, pie, both) (Score: 1)
| |
| +- Answer : No. Dieting is the price I pay to enjoy cake and/or pie.
| |
| +- Answer : Heck, no! You're crazy for even thinking that.
| |
| +- Are you offended at the thought of loving cake or pie less? (Available answers : Yes, no) (Score: 1)
| |
| +- Would you like some cake and/or pie right now? (Available answers : Yes, no) (Score: 1)
|
+- Answer : No, dieting is not something I need or want to do.
Checklist Two
|
+- Do you like coffee? (Available answers : Yes, no) (Score: 3)
|
+- Do you like tea? (Available answers : Yes, no) (Score: 3)
In the above view, you can see that there are multiple types of data.
The first is the root node - I show two, titled 'Checklist One' and 'Checklist Two'. As you can see, one is complex, while the other is simple.There will be multiple root nodes that all have multiple questions of varying depth that descend from them. I would like to have the ability to view multiple root nodes and all of the resulting questions, but my requirements only ask to see one at a time.
The next levels are characterized by questions that lead to further questions, or ending questions. You can see that each has a different structure.
Some questions may have further child questions. These questions have free-form answers possible and nothing else. These will never be at the root of the tree, but a given answer may terminate as a leaf. Furthermore, they can have no limit to how often one question descends from another. If you look at Checklist One, you can see a case where the non-root/non-leaf nodes go three levels deep before terminating in the end (leaf) questions, and how two free-form answers end with no further child questions. I would like to have as many levels of depth as possible, but it is unlikely that I will see more than three levels, as I have illustrated above.
Some questions never have child questions. These questions have a list of possible answers (yes, no, equally, both, cake, pie) and there is also an associated 'score'. This is entirely different from the questions above, so they will need to display their data differently. These questions are leaves in the tree. They will never be the root, but they may be connected to the root directly. (Look at Checklist Two for an example where there is a root node - Checklist Two - and two leaf nodes - the coffee question and the tea question. There are no middle nodes there.)
In my database, the root nodes are held in one table, the leaf questions are held in another, and the non-root/non-leaf questions are held in a looping parent-child structure in a third set of tables. Of course, I will be presenting the grid(s) with data via LINQ so the table structures themselves are not important, as I can just create anonymous objects to carry my data.
How should I build this grid? It seems that there is both self-referencing and multiple detail tables, but I haven't found a way to mix the two correctly in a RadGrid.