Flex基础-----之DataProvider

一、

<?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">
 <fx:Declarations>
  <!-- 将非可视元素(例如服务、值对象)放在此处 -->
 </fx:Declarations>
 <fx:Script>
  <![CDATA[
   import mx.collections.ArrayCollection;
   import mx.utils.UIDUtil;
   
   [Bindable]
   private var data:ArrayCollection=new ArrayCollection([
    {mx_internal_uid:UIDUtil.createUID(),userid:"a1",useridname:"张三"},
    {mx_internal_uid:UIDUtil.createUID(),userid:"a2", useridname:"李四"}, 
    {mx_internal_uid:UIDUtil.createUID(),userid:"a6", useridname:"路人乙"} ]);
  ]]>
 </fx:Script>
 <s:DataGrid name="dg_list" width="600" requestedRowCount="2" dataProvider="{data}" horizontalCenter="0" y="200" >
  <s:columns>
   <s:ArrayList>
    <s:GridColumn dataField="mx_internal_uid" headerText="列 1"></s:GridColumn>
    <s:GridColumn dataField="userid" headerText="列 2"></s:GridColumn>
    <s:GridColumn dataField="useridname" headerText="列 3"></s:GridColumn>
   </s:ArrayList>
  </s:columns>
 </s:DataGrid>
</s:Application>

二、

<?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">
 <fx:Declarations>
  <!-- 将非可视元素(例如服务、值对象)放在此处 -->
 </fx:Declarations>
 <s:DataGrid id="dataGrid" width="600" requestedRowCount="5" horizontalCenter="0" y="200">
  <s:ArrayCollection>
   <s:DataItem key="1000" name="Abrasive" price="100.11" call="false"/>
   <s:DataItem key="1001" name="Brush" price="110.01" call="true"/>
   <s:DataItem key="1002" name="Clamp" price="120.02" call="false"/>
   <s:DataItem key="1003" name="Drill" price="130.03" call="true"/>
   <s:DataItem key="1004" name="Epoxy" price="140.04" call="false"/>
   <s:DataItem key="1005" name="File" price="150.05" call="true"/>
   <s:DataItem key="1006" name="Gouge" price="160.06" call="false"/>
   <s:DataItem key="1007" name="Hook" price="170.07" call="true"/>
   <s:DataItem key="1008" name="Ink" price="180.08" call="false"/>
   <s:DataItem key="1009" name="Jack" price="190.09" call="true"/>            
  </s:ArrayCollection>
 </s:DataGrid>
</s:Application>

参考:

http://bbs.csdn.net/topics/390159047

http://bbs.9ria.com/thread-131489-1-1.html

http://blog.csdn.net/liruizhuang/article/details/5841480

http://yunzhongxia.iteye.com/blog/1133301

你可能感兴趣的:(Flex,dataprovider)