I am using a treeview to display projects, tasks, time entries, and the people who are working on a project. I would like to allow the user to define a custom grouping (ie. Project->Task->Time Entries or Project->Date (of time entry)->Task->TimeEntry).
The relevant groups would be Project, Task, Time Entry, and Person, with some metadata from them. I want to have some modular way to allow a user to specify how they would like to display the information.
Does anyone know of a good method by which this can be done? I currently have hard-coded a display which looks like this:
Project
Task
Time Entry
Next Project
...
My thought is to do something like write methods to display each type and somehow let a user select what order the display would group.
Please let me know if I am not being clear enough.
Here is one way:
Make a function to load a treeview node. Pass as a parameter the group types in hierarchical order: Project, Task, Time Entry, for example. The parameter could be an array or other type.
In the function, load the nodes with the items on the top of the hierarchy: Project first, in this example. For each project you add to the nodes collection, call the function recursively with all but the top item as the parameter — Task and Time Entry in this example, then time entry only at the third level of recursion.