Flex的資料基本操作(三)

來源:互聯網
上載者:User

上次不能顯示班級資料的問題,從表格中使用一個方法來讀取:

private function labFun(item:Object,col:DataGridColumn):String{return item.classes.id.toString();}如果需要,可以將此資料轉換為其它值。在表格的列中使用:
<mx:DataGridColumn headerText="班級" dataField="classes" labelFunction="labFun"/>

這樣在顯示資料時,將顯示班級的ID。

//-----------------------------------------------

建立一個組件User.mxml,作為一個視窗進行資料的新增及修改:

代碼:

<?xml version="1.0" encoding="utf-8"?><mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" width="304" height="246" title="資訊" creationComplete="this.getCombo()"><mx:Script><![CDATA[import mx.rpc.remoting.RemoteObject;import mx.collections.ArrayCollection;import mx.rpc.events.ResultEvent;import mx.managers.PopUpManager;private function closeBtn():void{PopUpManager.removePopUp(this);}private function okBtn():void{dispatchEvent(new Event("b1"));}//顯示庫中的班級資料private function getCombo():void{var obj:RemoteObject = new RemoteObject("GetClasses");obj.addEventListener(ResultEvent.RESULT, rOk);obj.GetAll();}private function rOk(evt:ResultEvent):void{this._bj.dataProvider = evt.result as ArrayCollection;}]]></mx:Script><mx:Form x="10" y="10"><mx:FormItem label="姓名"><mx:TextInput id="_xm"/></mx:FormItem><mx:FormItem label="年齡"><mx:TextInput id="_nl"/></mx:FormItem><mx:FormItem label="家庭住址"><mx:TextInput id="_jtzz"/></mx:FormItem><mx:FormItem label="班級"><mx:ComboBox id="_bj" labelField="classname"></mx:ComboBox></mx:FormItem><mx:FormItem><mx:HDividedBox width="100%"><mx:Button label="確定" click="this.okBtn()"/><mx:Button label="關閉" click="this.closeBtn();"/></mx:HDividedBox></mx:FormItem></mx:Form></mx:TitleWindow>

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.