Question

Any way to force a hierarchical detail (such as Project structure) to be expanded always?

Is there any way to have a hierarchical detail such as the Project Structure to be expanded always? Or a way to programmatically expand all nodes or collapse all nodes?

Like 0

Like

1 comments

Hello Ryan,

 

That is not possible to do with our out of the box functionality, but you can try implementing the following code:

 

    prepareResponseCollection: function(collection) {
                    var expandedHierarchyLevels = [];
                    
                    this.callParent(arguments);
                    collection.each(function(item) {
                        item.id = item.get(item.primaryColumnName);
                        expandedHierarchyLevels.push(item.get("Id"));
                    });
                    this.set("ExpandedLevelsByDefault", expandedHierarchyLevels);
                this.expandDefaultHierarchyLevels();
                },
                
            onRender: function() {
                this.callParent(arguments);
                this.expandDefaultHierarchyLevelsAfterRender();
            },

 // Needed to expand the elements in the Separate Mode
            expandDefaultHierarchyLevelsAfterRender: function() {
 
                var grid = this.getCurrentGrid();
                if (Ext.isEmpty(grid)) {
                    return;
                }
                var expandedHierarchyLevels = this.get("ExpandedLevelsByDefault");
                expandedHierarchyLevels.forEach(function(item) {
                    grid.toggleHierarchyFolding(item);
                });
            },

  // Needed to expand the elements in the Combined Mode when selecting a new record
            expandDefaultHierarchyLevels: function() {
 
                var grid = this.getCurrentGrid();
                if (Ext.isEmpty(grid)) {
                    return;
                }
                var expandedHierarchyLevels = this.get("ExpandedLevelsByDefault");
                expandedHierarchyLevels.forEach(function(item) {
                    grid.addExpandHierarchyLevel(item);
                });
            },

 

Best regards,

Dariy

Show all comments