Expand tree nodes at a specified hierarchy level
Expand tree nodes at a specified hierarchy level
You may want to expand tree nodes at a specified hierarchy level. For example, to see employees for a specific organizational unit, the user may use a filter console to specify the organizational unit.
To implement this feature, the application code can:
-
For each level of the hierarchy:
- Is this level is present in the console restriction, restrict the tree to display only nodes that meet the restriction.
- Expand all nodes on this level.
- Repeat for the next level down.
- Stop when there are no more levels, or when all console restriction clauses have been accounted for.
Example
Example code from /schema/ab-products/solutions/parts/tree/ab-ex-tree-after-get-data.js :
afterViewLoad: function() { // force the tree to hide parent nodes that do not have visible children this.exTreeAfterGetData_pmpTree.showNodesWithoutChildren = false; }, exTreeAfterGetData_pmpTree_onShowStepsWithHvac: function() { // override the function that add restriction clauses to the tree level restriction this.exTreeAfterGetData_pmpTree.updateRestrictionForLevel = function(parentNode, level, restriction) { // for the Trades tree level if (level === 2) { // display only HVAC trades restriction.addClause('pmpstr.res_id', 'HVAC', 'like'); } }; // re-query tree data this.exTreeAfterGetData_pmpTree.refresh(); // expand tree levels 0, 1, and 2 this.exTreeAfterGetData_pmpTree.expandAll(2);