Flex 3快速入门: 构建高级用户界面 创建项目编辑器3

Drop-in条目编辑器使用起来非常简单。但有主要缺点是你不能配置。通过<mx:Component>标签,可以创建一个组件作为内联条目编辑器。从而可以避免这个问题,是条目编辑器更灵活。


在下边的例子中,创建了一个包含NumericStepper控件的内联编辑器。因为此例中使用了内联编辑器,所以,可以设置NumericStepper的maximum和stepSize属性。


例子

Data model (artwork.xml)

<artwork> <piece> <name>The Wall</name> <image>artwork1.jpg</image> <price>250</price> <quantity>5</quantity> </piece> <piece> <name>Blue Flake</name> <image>artwork5.jpg</image> <price>400</price> <quantity>2</quantity> </piece> <piece> <name>Butterfly</name> <image>artwork6.jpg</image> <price>375</price> <quantity>17</quantity> </piece> </artwork>

MXML file

<?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" viewSourceURL="src/ItemEditorInline/index.html" width="525" height="525" > <mx:Model id="artwork" source="model/artwork.xml"/> <mx:DataGrid rowCount="3" variableRowHeight="true" dataProvider="{artwork.piece}" editable="true" > <mx:columns> <!-- Inline item renderer: Image control --> <mx:DataGridColumn dataField="image" headerText="Image" width="150" > <mx:itemRenderer> <mx:Component> <mx:VBox width="100%" height="140" horizontalAlign="center" verticalAlign="middle" > <mx:Image source="{'assets/'+data.image}"/> <mx:Label text="{data.image}" /> </mx:VBox> </mx:Component> </mx:itemRenderer> </mx:DataGridColumn> <mx:DataGridColumn headerText="Name" dataField="name"/> <mx:DataGridColumn headerText="Price" dataField="price"/> <!-- Inline item editor: NumericStepper --> <mx:DataGridColumn headerText="Quantity" dataField="quantity" editorDataField="value" > <mx:itemEditor> <mx:Component> <mx:NumericStepper maximum="100" stepSize="10" /> </mx:Component> </mx:itemEditor> </mx:DataGridColumn> </mx:columns> </mx:DataGrid> <mx:LinkButton textAlign="center" label="Photos (c) 2006 geishaboy500 (CC Attribution License)" click="{navigateToURL(new URLRequest('http://www.flickr.com/photos/geishaboy500/'));}" /> <mx:Script> <!--[CDATA[ import flash.net.navigateToURL; ]]--> </mx:Script> </mx:Application>

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值