FLEX 渲染器的簡單使用

來源:互聯網
上載者:User

      渲染器是FLEX中很常用的東東,很多地方都要用到,如做一個下拉樹,含有checkbox的datagrid等

     下面例子示範了渲染器如何與它的父組件進行傳值

 

      <?xml version="1.0" encoding="utf-8"?><br /><mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"><br /><mx:DataGrid x="66.5" y="145" id="dataGrid" dataProvider="{dataXml.children()}"><br /><mx:columns><br /><mx:DataGridColumn headerText="標籤" dataField="@label"/><br /><mx:DataGridColumn headerText="值" dataField="@value"><br /><mx:itemRenderer><br /><mx:Component><br /><mx:VBox><br /><mx:Script><br /><!--[CDATA[<br />[Bindable]<br />public var comboSource:Array=["true","false"];<br />/**初始化下拉框渲染器**/<br /> private function init():void<br />{<br />trace(data.@value);<br />if(data.@value=="true")<br />{<br />comboItem.selectedIndex=0;<br />}<br />else<br />{<br />comboItem.selectedIndex=1;<br />}<br />}</p><p>private function onComboClosed():void<br />{<br />data.@value=comboItem.text;<br />}<br />]]><br /></mx:Script><br /><mx:ComboBox dataProvider="{comboSource}" creationComplete="init();" id="comboItem" close="onComboClosed();"/><br /><!--<mx:ComboBox dataProvider="{comboSource}" id="comboItem" text="{data.@value}"/>--><br /></mx:VBox><br /></mx:Component><br /></mx:itemRenderer><br /></mx:DataGridColumn><br /></mx:columns><br /></mx:DataGrid><br /><mx:Script><br /><![CDATA[<br />import mx.controls.Alert;<br />[Bindable]<br />protected var dataXml:XML=<info><br /><aa label="24" value="false"/><br /><aa label="55" value="false"/><br /><aa label="23" value="true"/><br /><bb label="bb" value="false"/><br /></info>;</p><p>private function onButtonClicked():void<br />{<br />Alert.show(dataXml.toXMLString(),"datasource");<br />}</p><p>]]--><br /></mx:Script><br /><mx:Button x="66" y="115" label="Button" click="onButtonClicked();"/></p><p></mx:Application>

 

      從上例可以看出,渲染器和它的父組件進行傳值就是通過data這個對象的

     參考資料  google( flex itemRender 關鍵字)

     

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.