微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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://www.voidcn.com/article/p-rcqwdvni-mo.html

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

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐