<fx:Declarations> <fx:XMLList id="employees"> <employee> <name>Christina Coenraets</name> <birthday>2010-01-01</birthday> <age>1</age> <img>1.gif</img> </employee> <employee> <name>Joanne Wall</name> <birthday>2000-01-01</birthday> <age>10</age> <img>2.jpg</img> </employee> </fx:XMLList> </fx:Declarations> <!-- DataProvider 第二种方式: <fx:Script> <![CDATA[ var employees:ArrayCollection=new ArrayCollection([{name:"Christina Coenraets",birthday:new Date(2010,01,01),age:"1",img:"1.gif"},{name:"Joanne Wall",birthday:new Date(2010,01,01),age:"10",img:"2.jpg"}]); ]]> </fx:Script> --> <mx:DataGrid x="18" y="33" width="518" dataProvider="{employees}" dragEnabled="true" dropEnabled="true" dragMoveEnabled="true" editable="true"> <!-- dragEnabled:数据可以拖动,dropEnabled:可以添加别处拖来的数据,dragMoveEnabled:删除拖走的数据,editable:可编辑 --> <mx:columns> <mx:DataGridColumn headerText="name" dataField="name"> <mx:itemRenderer> <fx:Component> <s:MXDataGridItemRenderer> <s:HGroup> <s:Label text="{data.email}" /> <mx:Image source="{data.img}" /> </s:HGroup> </s:MXDataGridItemRenderer> </fx:Component> </mx:itemRenderer> <!-- itemRenderer:自定义数据行,可放置其他控件 --> </mx:DataGridColumn> <mx:DataGridColumn headerText="birthday" dataField="birthday" itemEditor="mx.controls.DateField" editorDataField="selectedDate" /> <!-- itemEditor:编辑控件,editorDataField:编辑值的来自此属性 --> <mx:DataGridColumn dataField="age" headerText="age" editorDataField="value"> <mx:itemEditor> <fx:Component> <mx:NumericStepper stepSize="1" minimum="1" maximum="150" /> </fx:Component> </mx:itemEditor> <!-- 自定义编辑控件 --> </mx:DataGridColumn> </mx:columns> </mx:DataGrid>