Posts Tagged datagroup

[Flex] Flex 4 DataGroup

Flex 3 大家都有用的一個component 都應該是repeater.

但到了flex 4 之後,就改為datagroup。

不過其實用法就無改變呢~

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
 
<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" width="500" height="200" initialize="init()" viewSourceURL="srcview/index.html">
 
    <fx:Script>
        <![CDATA[
            import mx.collections.ArrayCollection;
 
            [Bindable] public var productData:ArrayCollection;
 
            private function init():void {
 
                productData = new ArrayCollection();
                productData.addItem({"name":"Chocolate","price":"3"});
                productData.addItem({"name":"Beer","price":"5"});
                productData.addItem({"name":"Candy","price":"2"});              
            }
 
        ]]>
    </fx:Script>
 
    <fx:Declarations>
        <
    </fx:Declarations>
 
    <s:DataGroup itemRenderer="ProductsRenderer" dataProvider="{productData}" rollOverColor="0xFFCC00">
        <s:layout>
            <s:VerticalLayout horizontalAlign="center"/>
        </s:layout>     
    </s:DataGroup>
</s:Application>
1
2
3
4
5
6
7
8
9
10
11
<s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx" 
                autoDrawBackground="true">
    <s:layout>
        <s:HorizontalLayout verticalAlign="middle" />       
    </s:layout>
    <s:Label text="{data.name}:" width="100" fontWeight="bold" />
    <s:TextInput text="${data.price}" width="50" />
 
</s:ItemRenderer>

Source: http://www.flex-blog.com/flex-4-flash-builder-4-repeater-changed-to-datagroup/

Share

, ,

No Comments