Flex中TitleWindow傳值思路及實(shí)現(xiàn)
1、設(shè)計(jì)思路
(1)新建一個(gè)DataGrid,在其中最后一列加入三個(gè)按鈕:新增、修改和刪除;
(2)點(diǎn)擊新增按鈕,可以將表格新增一行;
(3)單擊“修改”按鈕,可以修改表格中該行的一些屬性;
(4)單擊“刪除”按鈕,會將表格中該行刪除。
2、實(shí)現(xiàn)步驟
(1)新建一個(gè)應(yīng)用程序,DataGrid.mxml
DataGrid.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Declarations>
<!-- 將非可視元素(例如服務(wù)、值對象)放在此處 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
[Bindable]
//表格數(shù)據(jù)源綁定
private var grid:ArrayCollection = new ArrayCollection([
{number:"2014010101",name:"張三",sex:"男",age:"19"},
{number:"2014010102",name:"李思",sex:"女",age:"20"},
{number:"2014010103",name:"蔡華",sex:"男",age:"21"},
{number:"2014010104",name:"牛耳",sex:"女",age:"22"},
{number:"2014010105",name:"兆司",sex:"男",age:"18"},
{number:"2014010106",name:"胡柳",sex:"女",age:"19"},
{number:"2014010107",name:"劉斯",sex:"男",age:"20"},
{number:"2014010108",name:"孫陽",sex:"女",age:"22"},
{number:"2014010109",name:"鄭武",sex:"男",age:"21"},
{number:"2014010110",name:"王雪",sex:"女",age:"20"},
{number:"2014010111",name:"胡柳",sex:"女",age:"19"},
{number:"2014010112",name:"劉斯",sex:"男",age:"20"},
{number:"2014010113",name:"孫陽",sex:"女",age:"22"},
{number:"2014010114",name:"鄭武",sex:"男",age:"21"},
{number:"2014010115",name:"王雪",sex:"女",age:"20"}
]);
]]>
</fx:Script>
<mx:VBox width="100%" height="100%" paddingBottom="100" paddingLeft="100" paddingRight="100" paddingTop="100">
<mx:DataGrid id="dataGrid" dataProvider="{grid}" rowCount="{grid.length+1}" width="100%" textAlign="center">
<mx:columns>
<mx:DataGridColumn headerText="學(xué)號" dataField="number" id="stuNumber"/>
<mx:DataGridColumn headerText="姓名" dataField="name"/>
<mx:DataGridColumn headerText="性別" dataField="sex"/>
<mx:DataGridColumn headerText="年齡" dataField="age"/>
<mx:DataGridColumn headerText="操作">
<mx:itemRenderer>
<fx:Component>
<mx:HBox width="100%" paddingLeft="40">
<fx:Script>
<![CDATA[
import mx.managers.PopUpManager;
/*添加按鈕事件函數(shù)*/
protected function addHandler(event:MouseEvent):void
{
var childWindow:ChildWindow = ChildWindow(PopUpManager.createPopUp(this,ChildWindow,true));
var point:Point = new Point(100,100);
childWindow.x = point.x + 400;
childWindow.y = point.y + 50;
}
/*修改按鈕事件函數(shù)*/
protected function updateHandler(event:MouseEvent):void
{
var updateWindow:UpdateWindow = UpdateWindow(PopUpManager.createPopUp(this,UpdateWindow,true));
var point:Point = new Point(100,100);
updateWindow.x = point.x + 400;
updateWindow.y = point.y + 50;
updateWindow.stuNo = event.currentTarget.selectedItem.content;
}
]]>
</fx:Script>
<mx:LinkButton label="新增" click="addHandler(event)"/>
<s:Label width="10"/>
<mx:LinkButton label="修改" click="updateHandler(event)"/>
<s:Label width="10"/>
<mx:LinkButton label="刪除"/>
</mx:HBox>
</fx:Component>
</mx:itemRenderer>
</mx:DataGridColumn>
</mx:columns>
</mx:DataGrid>
</mx:VBox>
</s:Application>
(2)新建一個(gè)新增窗口組件,ChildWindow.mxml
ChildWindow.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"
close="closeHandler(event)" title="新增窗口">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
/*關(guān)閉按鈕函數(shù)*/
protected function closeHandler(event:CloseEvent):void
{
PopUpManager.removePopUp(this);
}
/*取消按鈕函數(shù)*/
protected function cancelHandler(event:MouseEvent):void
{
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 將非可視元素(例如服務(wù)、值對象)放在此處 -->
</fx:Declarations>
<mx:VBox width="100%" height="100%" horizontalAlign="center">
<mx:Form borderStyle="solid" borderColor="#CCCCCC" width="100%">
<mx:FormHeading label="新增界面" fontSize="14"/>
<mx:FormItem label="學(xué)號:">
<s:TextInput id="stuNo" width="200"/>
</mx:FormItem>
<mx:FormItem label="姓名:">
<s:TextInput id="stuName" width="200"/>
</mx:FormItem>
<mx:FormItem label="性別:">
<s:TextInput id="stuSex" width="200"/>
</mx:FormItem>
<mx:FormItem label="年齡:">
<s:TextInput id="stuAge" width="200"/>
</mx:FormItem>
</mx:Form>
<mx:HBox width="100%" height="25">
<s:Label width="60"/>
<s:Button label="新增"/>
<s:Label width="48"/>
<s:Button label="取消" click="cancelHandler(event)"/>
</mx:HBox>
</mx:VBox>
</s:TitleWindow>
(3)新建一個(gè)修改界面組件,UpdateWindow.mxml
UpdateWindow.mxml:
<?xml version="1.0" encoding="utf-8"?>
<s:TitleWindow xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"
close="closeHandler(event)" title="修改窗口">
<s:layout>
<s:BasicLayout/>
</s:layout>
<fx:Script>
<![CDATA[
import mx.events.CloseEvent;
import mx.managers.PopUpManager;
/*關(guān)閉按鈕函數(shù)*/
protected function closeHandler(event:CloseEvent):void
{
PopUpManager.removePopUp(this);
}
/*取消按鈕函數(shù)*/
protected function cancelHandler(event:MouseEvent):void
{
PopUpManager.removePopUp(this);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- 將非可視元素(例如服務(wù)、值對象)放在此處 -->
</fx:Declarations>
<mx:VBox width="100%" height="100%" horizontalAlign="center">
<mx:Form borderStyle="solid" borderColor="#CCCCCC" width="100%">
<mx:FormHeading label="修改界面" fontSize="14"/>
<mx:FormItem label="學(xué)號:">
<s:TextInput id="stuNo" width="200"/>
</mx:FormItem>
<mx:FormItem label="姓名:">
<s:TextInput id="stuName" width="200"/>
</mx:FormItem>
<mx:FormItem label="性別:">
<s:TextInput id="stuSex" width="200"/>
</mx:FormItem>
<mx:FormItem label="年齡:">
<s:TextInput id="stuAge" width="200"/>
</mx:FormItem>
</mx:Form>
<mx:HBox width="100%" height="25">
<s:Label width="60"/>
<s:Button label="修改"/>
<s:Label width="48"/>
<s:Button label="取消" click="cancelHandler(event)"/>
</mx:HBox>
</mx:VBox>
</s:TitleWindow>
3、設(shè)計(jì)結(jié)果
(1)初始化時(shí)
上一篇:flex導(dǎo)出excel具體實(shí)現(xiàn)
欄 目:Flex
下一篇:使用flex中的httpservice方法與java進(jìn)行交互
本文標(biāo)題:Flex中TitleWindow傳值思路及實(shí)現(xiàn)
本文地址:http://mengdiqiu.com.cn/a1/Flex/11584.html
您可能感興趣的文章
- 01-11flex調(diào)用webservice中的自定義類的方法
- 01-11Flex實(shí)現(xiàn)的上傳攝像頭拍照并將UI保存為圖片
- 01-11Flex字體加粗問題只能對英文的字體加粗
- 01-11flex利用webservice上傳照片實(shí)現(xiàn)代碼
- 01-11Flex控制彈出窗口拖動(dòng)范圍示例代碼
- 01-11flex內(nèi)嵌html網(wǎng)頁示例代碼
- 01-11Flex中在Tree綁定數(shù)據(jù)后自動(dòng)展開樹節(jié)點(diǎn)的方法
- 01-11Flex彈出窗口請求Action函數(shù)示例
- 01-11Flex中通過RadioButton進(jìn)行切換示例代碼
- 01-11Flex中TabNavigator設(shè)置Tabs樣式思路及源碼


閱讀排行
本欄相關(guān)
- 01-11flex調(diào)用webservice中的自定義類的方法
- 01-11Flex實(shí)現(xiàn)的上傳攝像頭拍照并將UI保存
- 01-11datagrid不可編輯行有關(guān)問題的控制方法
- 01-11Flex控制彈出窗口拖動(dòng)范圍示例代碼
- 01-11flex利用webservice上傳照片實(shí)現(xiàn)代碼
- 01-11Flex字體加粗問題只能對英文的字體加
- 01-11Flex中在Tree綁定數(shù)據(jù)后自動(dòng)展開樹節(jié)點(diǎn)
- 01-11flex內(nèi)嵌html網(wǎng)頁示例代碼
- 01-11Flex中通過RadioButton進(jìn)行切換示例代碼
- 01-11Flex彈出窗口請求Action函數(shù)示例
隨機(jī)閱讀
- 01-11ajax實(shí)現(xiàn)頁面的局部加載
- 01-10SublimeText編譯C開發(fā)環(huán)境設(shè)置
- 08-05織夢dedecms什么時(shí)候用欄目交叉功能?
- 08-05dedecms(織夢)副欄目數(shù)量限制代碼修改
- 04-02jquery與jsp,用jquery
- 08-05DEDE織夢data目錄下的sessions文件夾有什
- 01-11Mac OSX 打開原生自帶讀寫NTFS功能(圖文
- 01-10C#中split用法實(shí)例總結(jié)
- 01-10delphi制作wav文件的方法
- 01-10使用C語言求解撲克牌的順子及n個(gè)骰子