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>
1131

被折叠的 条评论
为什么被折叠?



