Monday, May 11, 2009

Creating Data Grid Using HTTP Service in Flex

Creating Data Grid Using HTTP Service in Flex & displaying data using XML in flex.



<?xml version='1.0' />
<Data>
<ID>1</ID>
<Name>Vineet</Name>
</Data>
<Data>
<ID>2</ID>
<Name>Abhishek</Name>
</Data>


This Data Grid Example will display above xml data in grid.


<mx:application mx="http://www.adobe.com/2006/mxml"
layout="absolute"
creationcomplete="init()">

<mx:httpservice id="xmlFile" url="http://localhost/***/***/project.php" result="getXML(event)" resultformat="e4x" />
<mx:script>

<!--[CDATA[
import mx.rpc.events.ResultEvent;
[Bindable]
-->
</mx:script>

<mx:panel x="10" y="10" width="100%" height="100%">
<mx:canvas label="XYZ" width="100%" height="100%">
<mx:datagrid x="10" y="10" width="100%" height="100%" dataprovider="{xmlHandler}">
<mx:columns>
<mx:datagridcolumn width="82" headertext="ID" datafield="ID">
<mx:datagridcolumn headertext="name" datafield="Name">
</mx:datagridcolumn>
</mx:datagridcolumn>
</mx:columns>
</mx:datagrid>

</mx:canvas>
</mx:panel>
</mx:application>

No comments:

Post a Comment