Using CF 7.02 and Datagrids is very easy now!

Remember that the column names come through in CAPS.

Example I wrote after the Flex Data Services session to test the speed of webservices.

<?xml version="1.0" encoding="utf-8"?>

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

<!-- setup the webservice to call -->

<mx:WebService id="wsc" wsdl="http://www.getpaidtoseeads.com/seeEmail.cfc?wsdl" showBusyCursor="true" useProxy="false">

<!-- this allows for a parameter to be passed I am sending the MaxRows parameter in the cfquery tag -->

<mx:operation name="GetPostalCode">

<mx:request xmlns="">

<MaxRow>

{cbxMaxRow.value}

</MaxRow>

</mx:request>

</mx:operation>

</mx:WebService>

<!-- this is a combo box to select the rows to bring in -->

<mx:Button label="Get Records" click="wsc.GetPostalCode.send()" left="412" top="10"/>

<mx:ComboBox id="cbxMaxRow" left="100" top="10">

<mx:Object label="100" value="100" />

<mx:Object label="500" value="500" />

<mx:Object label="1000" value="1000" />

<mx:Object label="10000" value="10000" />

<mx:Object label="20000" value="20000" />

<mx:Object label="40000" value="40000" />

</mx:ComboBox>

<!-- here is the easy part! see how the dataprovider is the webservice no extra arraycollection needed Format is webservice id then method or function name then lastResult-->

<mx:DataGrid id="dgEmail" width="816" height="469" dataProvider="{wsc.GetPostalCode.lastResult}" x="50" y="100">

<mx:columns>

<!-- see how my dataField names are in caps it will not show data without that CF and FLex work that way -->

<mx:DataGridColumn headerText="Subscriber" dataField="PKID"/>

<mx:DataGridColumn headerText="Postal Code" dataField="POSTALCODE"/>

<mx:DataGridColumn headerText="Province" dataField="PROVINCE"/>

</mx:columns>

</mx:DataGrid>

</mx:Application>

 

See if that makes life easier for you and all the CFer's out there.

Kindest Regards,

 

Eric


--- In [email protected], "michrx7" <[EMAIL PROTECTED]> wrote:
>
> I am trying to populate a datagrid with results from a cfc. This
> should be simple. I have written the simply "Hello World" cfc and
> gotten the string to display, but am really struggling getting a
> query to return and display. If someone would help it would be
> appreciated.
>
> Here is my CFC (getInfo.cfc):
> <CFCOMPONENT displayname="admin_rpt_AllMembers">
> <CFFUNCTION name="getCompany" access="remote"
> returntype="query">
> <CFQUERY datasource="myDatabase" name="getMem">
> SELECT cvcontactID, cvcontactLast,
> cvcontactFirst FROM cvContact
> </CFQUERY>
> <CFRETURN getMem>
> </CFFUNCTION>
> </CFCOMPONENT>
>
> Pretty straightforward as I'm only selecting some simple info out of
> the database.
>
> Now I have my flex app that should call the cfc, return the query,
> and list the info into a simple datagrid. Now I know it's making the
> calls to the cfc (using simple Alert.show() calls), but I can't get
> the data to display.
>
> Here is my mxml flex file:
> <?xml version="1.0" encoding="utf-8"?>
> <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
> layout="vertical" creationComplete="initApp();">
> <mx:Script>
> <![CDATA[
> import mx.collections.ArrayCollection;
> import mx.rpc.events.*;
> import mx.controls.Alert;
>
> [Bindable]
> public var companyInfo:ArrayCollection = null;
>
>
> public function initApp():void
> {
> myService.getCompany();
> }
>
> public function resultHandler(event:ResultEvent):void
> {
> var p1:ArrayCollection = new ArrayCollection();
> p1.source = event.result as Array;
> companyInfo = p1;
> }
>
> ]]>
> </mx:Script>
>
> <mx:RemoteObject id="myService" destination="ColdFusion"
> source="admin_rpt_AllMembers" showBusyCursor="true">
>
> <mx:method name="getCompany" result="resultHandler
> (event)" fault="Alert.show(event.fault.message)"/>
>
> </mx:RemoteObject>
>
> <mx:DataGrid name="myGrid" id="myGrid" width="100%"
> height="100%" dataProvider="{companyInfo}">
> <mx:columns>
> <mx:DataGridColumn headerText="ID" dataField="cvcontactID"/>
> <mx:DataGridColumn headerText="Last Name"
> dataField="cvcontactLast"/>
> <mx:DataGridColumn headerText="First Name"
> dataField="cvcontactFirst"/>
> </mx:columns>
> </mx:DataGrid>
>
> <mx:Button click="initApp()"/>
>
> </mx:Application>
>
> I am completely at a loss right now on where to try and change
> anything. Thanks for the help in advance.
>

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





YAHOO! GROUPS LINKS




__,_._,___

Reply via email to