<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    posts - 325,  comments - 25,  trackbacks - 0
     

    15.項呈現器創建方法:

        1)內投方法:通過在列表控件的itemRenderer屬性中定義單個組件,能夠將插入的單個組件作為項呈現器

        2)內聯方法:使用列表控件的子標簽來定義一個或多個組件,這些組件將作為項呈現器

        3)可重用組件:將自定義組件作為項呈現器

    內投方法示例:

        

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

     <mx:Script>

     <![CDATA[

      

       [Bindable]

       privatevar myDP:Array = [

        {label: "Customer 1", selected: true},

        {label: "Customer 2", selected: false}

       ];

      

     ]]>

     </mx:Script>

     

     <mx:DataGrid dataProvider="{myDP}">

     <mx:columns>

       <mx:DataGridColumn dataField="label" headerText="Label" />

       <mx:DataGridColumn dataField="selected" itemRenderer="mx.controls.CheckBox" />

     </mx:columns>

     </mx:DataGrid>

     

    </mx:Application>

    內聯方法示例:

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

     <mx:Script>

     <![CDATA[

      

       [Bindable]

       privatevar myDP:Array = [

        {label: "Customer 1", selected: true},

        {label: "Customer 2", selected: false}

       ];

      

     ]]>

     </mx:Script>

     

     <mx:DataGrid dataProvider="{myDP}">

     <mx:columns>

       <mx:DataGridColumn dataField="label" headerText="Label" />

       <mx:DataGridColumn dataField="selected">

        <mx:itemRenderer>

         <mx:Component>

          <mx:VBox verticalAlign="middle" horizontalAlign="center">

           <mx:CheckBox/>

          </mx:VBox>

         </mx:Component>

        </mx:itemRenderer>

       </mx:DataGridColumn>

     </mx:columns>

     </mx:DataGrid>

    </mx:Application>

    將組件作為呈現器示例:

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

     <mx:Script>

     <![CDATA[

      

       [Bindable]

       privatevar myDP:Array = [

        {label: "Oranges", date: new Date()},

        {label: "Apples", date: new Date()},

        {label: "Pears", date: new Date()}

       ];

      

     ]]>

     </mx:Script>

     

     <mx:List dataProvider="{myDP}" itemRenderer="MyCustomItemRenderer" />

     

    </mx:Application>

    MyCustomItemRenderer.xml

    <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">

     

     <mx:Script>

     <![CDATA[

       import mx.controls.Alert;

     ]]>

     </mx:Script>

     

     <mx:HBox>

     <mx:TextInput text="{data.label}" />

     <mx:DateField id="dateField" selectedDate="{data.date}" />

     <mx:Button label="Button" click="Alert.show('Selected item - Fruit: ' + data.label + '"n' + 'Date: ' + dateField.selectedDate)" />

     </mx:HBox>

    </mx:HBox>
    16.項編輯器
    編輯過程:
    a) 用戶利用鼠標按鈕或者tab鍵激活單元格
    b) 分派itemEditBeginning 事件,使用該事件能夠禁用某特定單元格或者多個單元格的編輯功能
    c) 分派itemEditBegin事件以便打開項編輯器,該事件可用于修改傳遞給項編輯器數據
    d)用戶編輯單元格數據
    e)用戶移除焦點時,結束編輯會話
    f)分派itemEditEnd 事件以便關閉項編輯器,同時使用新數據更新單元格

    當列表控件(List Tree DataGrid)的editable屬性設置為true時,用戶就能夠編輯控件內容

    自定義編輯事件監聽器訪問單元格數據:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

     <mx:Script>
      <![CDATA[
       import mx.controls.TextInput;
       import mx.events.DataGridEvent;
       import mx.collections.ArrayCollection;
       
       [Bindable]
       private var productsAC:ArrayCollection = new ArrayCollection
       (
        [
         {Product: "iPod", Price: 249},
         {Product: "iMac", Price: 1299},
         {Product: "MacBook Pro", Price: 1999}
        ]
       );
       
       private function getCellInfo(event:DataGridEvent):void
       {
        var myEditor:TextInput = TextInput(event.currentTarget.itemEditorInstance);
        var newVal:String = myEditor.text;
        var oldVal:String = event.currentTarget.editedItemRenderer.data[event.dataField];
        cellInfo.text = "cell edited. \n";
        cellInfo.text += "Row, column: " + event.rowIndex + ", " + event.columnIndex + "\n";
        cellInfo.text += "New value: " + newVal + "\n";
        cellInfo.text += "Old value: " + oldVal;
       }
       
      ]]>
     </mx:Script>
     
     <mx:TextArea id="cellInfo" width="300" height="150" />
     
     <mx:DataGrid dataProvider="{productsAC}" editable="true" itemEditEnd="getCellInfo(event)">
      <mx:columns>
       <mx:DataGridColumn dataField="Product" />
       <mx:DataGridColumn dataField="Price" />
      </mx:columns>
     </mx:DataGrid>
     
    </mx:Application>
    禁用單元格編輯器:

    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">

     <mx:Script>
      <![CDATA[
       import mx.controls.TextInput;
       import mx.events.DataGridEvent;
       import mx.collections.ArrayCollection;
       
       [Bindable]
       private var productsAC:ArrayCollection = new ArrayCollection
       (
        [
         {Product: "iPod", Price: 249},
         {Product: "iMac", Price: 1299},
         {Product: "MacBook Pro", Price: 1999}
        ]
       );
       
       private function onEditBeginning(event:DataGridEvent):void
       {
        if (event.rowIndex == 2)
         event.preventDefault();
       }
       
      ]]>
     </mx:Script>
     
     <mx:DataGrid dataProvider="{productsAC}" editable="true" itemEditBeginning="onEditBeginning(event)">
      <mx:columns>
       <mx:DataGridColumn dataField="Product" />
       <mx:DataGridColumn dataField="Price" />
      </mx:columns>
     </mx:DataGrid>
     
    </mx:Application>



    posted on 2011-03-14 09:50 長春語林科技 閱讀(369) 評論(0)  編輯  收藏 所屬分類: flex
    <2011年3月>
    272812345
    6789101112
    13141516171819
    20212223242526
    272829303112
    3456789

     

    長春語林科技歡迎您!

    常用鏈接

    留言簿(6)

    隨筆分類

    隨筆檔案

    文章分類

    文章檔案

    相冊

    收藏夾

    搜索

    •  

    最新評論

    閱讀排行榜

    評論排行榜

    主站蜘蛛池模板: 无码日韩精品一区二区三区免费| 亚洲性无码av在线| 亚洲综合国产精品第一页| 国产精品自在自线免费观看| 成人性生交视频免费观看| 久久国内免费视频| 国产免费一区二区三区| free哆啪啪免费永久| 精品国产无限资源免费观看| 18勿入网站免费永久| 91免费精品国自产拍在线不卡| 很黄很黄的网站免费的| 欧洲精品成人免费视频在线观看| 无码人妻久久一区二区三区免费丨| 波多野结衣中文字幕免费视频| 亚洲成在人线aⅴ免费毛片| 天天操夜夜操免费视频| 国产女高清在线看免费观看| 亚洲精品国产高清嫩草影院| 国产亚洲精品国产| 亚洲精品欧洲精品| 亚洲熟女精品中文字幕| 视频免费1区二区三区| a级男女仿爱免费视频| 99久久精品国产免费| 青娱乐免费在线视频| 国产精品麻豆免费版| 亚洲日韩中文无码久久| 亚洲精品成人av在线| 学生妹亚洲一区二区| 免费无码AV一区二区| 国产精品白浆在线观看免费| 国产成人精品免费午夜app| 在线观看免费大黄网站| avtt亚洲天堂| 亚洲av无码av制服另类专区| 亚洲黄色在线观看网站| 亚洲欧美成人一区二区三区| 久久精品无码免费不卡| 国产曰批免费视频播放免费s| 大学生美女毛片免费视频|