全部展开树节点

 
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">
    
<mx:Script>
        
<![CDATA[
            private function expandTree(expand:Boolean):void {
                tree.validateNow();
                tree.expandChildrenOf(treeData, expand);
            }
        
]]>
    
</mx:Script>
    
<mx:XML id="treeData" xmlns="">
        
<root label="root">
            
<menu label="node1">
                
<menu label="node1.1"/>
                
<menu label="node1.2"/>
                
<menu label="node1.3"/>
            
</menu>
            
<menu label="node2">
                
<menu label="node2.1"/>
                
<menu label="node2.2"/>
                
<menu label="node2.3"/>
            
</menu>
        
</root>        
    
</mx:XML>
    
<mx:Tree id="tree" dataProvider="{treeData}" 
        width
="200" height="300"
        labelField
="@label"/>
    
<mx:Button label="全部展开" click="expandTree(true)"/>
    
<mx:Button label="全部收起" click="expandTree(false)"/>
</mx:Application>
阅读更多
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页