Hello,
I have a question regarding the nested tree functionality.
If I were to use the nested tree to display an organization's structure, is it possible to do the following?
<department1>
<departmentA>
<departmentA1>
<departmentA2>
<departmentB>
<departmentB1>
<departmentC>
<department2>
<departmentD>
If so, how do I construct the rules?
I have one sql query to determine the top levels (ex: department1, department2), and then the next sql query would have to loop through those top levels, and determine the next layer (ex: for department1 -> departmentA, departmentB, and departmentC) and so forth.
I'm not sure how to construct the rules so that the resulting xml would show the appropriate structure, or if that's possible.
I have a question regarding the nested tree functionality.
If I were to use the nested tree to display an organization's structure, is it possible to do the following?
<department1>
<departmentA>
<departmentA1>
<departmentA2>
<departmentB>
<departmentB1>
<departmentC>
<department2>
<departmentD>
If so, how do I construct the rules?
I have one sql query to determine the top levels (ex: department1, department2), and then the next sql query would have to loop through those top levels, and determine the next layer (ex: for department1 -> departmentA, departmentB, and departmentC) and so forth.
I'm not sure how to construct the rules so that the resulting xml would show the appropriate structure, or if that's possible.
RE: Nested Tree functionality
I have attached an example project (v7) that hopefully illustrates a couple of approaches for this.
This is based on a simple 'department' table that contains three columns: id, name, and parent. The parent column contains the id of the parent department record, or null if it is at the top level.
If this is a similar approach to how your data is stored, then the easiest option is probably the first approach in this project.
This simply does a query to retrieve all the records from the database table, and then uses an XSL transform to format this information into the nested structure used by the tree.
Alternatively, if you do need to do separate queries to retrieve each set of lower level departments, then you will need to look at the second approach.
This does an initial query to just return the top level departments, and then has a second rule that makes use of the forward chaining rulebase option, to process the next found department until they have all been checked.
The forward chaining option has to be enabled under 'RuleBase Settings', and when turned on means that after a rule has finished, all the rules are rechecked to decide which one to fire next.
The 'process all departments not yet checked' rule finds the first department for which we have not yet looked for sub departments, and performs a SQL query for it. The results of this get added into the data, and any new departments found will be processed at some point in the future by this same rule.
Finally, once there are no more departments to process, a transform is again used to structure the information into the format needed for the tree.
I hope this example project helps you with your requirements.
Let me know if you have any questions.
Regards,
Gerard