zoukankan      html  css  js  c++  java
  • flex下的树形下拉框treecombobox

    不多说了,组件代码如下:
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <mx:ComboBox  xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initComponent()">
    3. <mx:Script>
    4.     <![CDATA[
    5.            import mx.events.FlexEvent; 
    6.            [Bindable] 
    7.            private var _label:String; 
    8.            [Bindable] 
    9.            public var treeSelectedItem:Object;
    10.            public function initComponent():void
    11.            {
    12.             
    13.            }
    14.                         
    15.            public function updateLabel(event:*):void{  
    16.                     _label = event.currentTarget.selectedItem[this.labelField];     
    17.                     treeSelectedItem = event.currentTarget.selectedItem; 
    18.            } 
    19.            
    20.            override protected function updateDisplayList(unscaledWidth:Number,
    21.                                                   unscaledHeight:Number):void
    22.             {
    23.                 super.updateDisplayList(unscaledWidth, unscaledHeight);  
    24.                 
    25.                 if(dropdown && _label != null){   
    26.                     text = _label; 
    27.                 } 
    28.             }
    29.              
    30.     ]]>
    31. </mx:Script>
    32.     <mx:dropdownFactory>
    33.       <mx:Component> 
    34.         <mx:Tree creationComplete="initTree()" change="outerDocument.updateLabel(event)" showRoot="true" height="500" width="500">
    35.          <mx:Script>
    36.                 <![CDATA[
    37.                 public function initTree():void {
    38.                     var len:int=super.dataProvider.length;
    39.                     for(var i:int;i<len;i++)
    40.                     {
    41.                         super.expandChildrenOf(super.dataProvider[i], true);
    42.                     }
    43.                     super.selectedItem=outerDocument.treeSelectedItem;
    44.                 }
    45.                 ]]>
    46.             </mx:Script>
    47.         </mx:Tree>
    48.      </mx:Component>
    49.     </mx:dropdownFactory>
    50. </mx:ComboBox>
    调用的app代码如下:
    1. <?xml version="1.0" encoding="utf-8"?>
    2. <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:ns1="components.*">
    3.     <ns1:ComboTree  width="300" id="combo" labelField="@label" >
    4.         <mx:XMLListCollection id="MailBox">
    5.             <mx:XMLList>
    6.                 <folder label="Mail">
    7.                  <folder label="INBOX"/>
    8.                  <folder label="Personal Folder">
    9.                     <Pfolder label="Business" />
    10.                      <Pfolder label="Demo" /> 
    11.                          <Pfolder label="Personal" isBranch="true" /> 
    12.                          <Pfolder label="Saved Mail" /> 
    13.                     </folder>
    14.                     <folder label="Sent" />
    15.                     <folder label="Trash" />
    16.                 </folder>
    17.                 <folder label="Mail2">
    18.                  <folder label="INBOX2"/>
    19.                  <folder label="Personal Folder2">
    20.                     <Pfolder label="Business2" />
    21.                      <Pfolder label="Demo2" /> 
    22.                          <Pfolder label="Personal2" isBranch="true" /> 
    23.                          <Pfolder label="Saved Mail2" /> 
    24.                     </folder>
    25.                     <folder label="Sent2" />
    26.                     <folder label="Trash2" />
    27.                 </folder>
    28.             </mx:XMLList>
    29.         </mx:XMLListCollection>
    30.     </ns1:ComboTree>
    31. </mx:Application>


  • 相关阅读:
    [Leetcode]@python 76. Minimum Window Substring
    [Leetcode]@python 75. Sort Colors
    HTNL表单
    第二天
    开学心德
    HTML表单
    网页制作
    2nd day
    开课心得
    CF10D/POJ2127 LCIS 题解
  • 原文地址:https://www.cnblogs.com/hainange/p/6153268.html
Copyright © 2011-2022 走看看