<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()">

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="initApp()">

http://www.manfridayconsulting.it/index.php?option=com_content&view=article&id=42:datagrid-binded-to-httpservice&catid=12:flex-3&Itemid=27

DataGrid binded to HTTPService
Lunedì 26 Gennaio 2009 20:23
How to consume an HTTPService using Xml Object. You can see the power of Databinding in this environment.
You only need to set the property dataProvider="{productsarray}" of the DataGrid to get all objects coming from
on results function.
 
Here an example of Xml object definition 
< dataroot>
< product>
< id>1</ id>
< total>2</ total>
< name>Motherboard</ name>
< price>100</ price>
</ product>
< product>
< id>2</ id>
< total>2</ total>
< name>Pprocessor</ name>
< price>150</ price>
</ product>

</ dataroot>

 
Now we start with the sample application:  
 
< mx:Application
xmlns:mx=" http://www.adobe.com/2006/mxml"
layout=" absolute"
creationComplete=" initApp()">
< mx:HTTPService id=" srv" url=" services/products.xml"
resultFormat=" object"
result=" onResult(event)"/>
< mx:DataGrid id=" grid"
width=" 100%"
height=" 100%"
dataProvider=" {productsarray}">
< mx:columns>
< mx:DataGridColumn headerText=" Total No."
dataField=" total"/>
< mx:DataGridColumn headerText=" Name"
dataField=" name"/>
< mx:DataGridColumn headerText=" Price"
dataField=" price"/>
</ mx:columns>
</ mx:DataGrid>
< mx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[ Bindable]
private var productsarray:ArrayCollection;
private function initApp(): void {
this.srv.send();
}
private function onResult(evt:ResultEvent): void {
this.productsarray = evt.result.data.product;
}
]]>
</ mx:Script>
</ mx:Application>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值