import mx.collections.ArrayCollection;
import mx.rpc.events.ResultEvent;
[Bindable]
private var companyInfo:ArrayCollection;
private function resultHandler(event:ResultEvent):void {
companyInfo = event.result as ArrayCollection;
}
Essentially, the array type returned by ColdFusion is not exactly the same type of array that the Datagrid is expecting. So you have to "coerce" it into the correct datatype, which is what the "as ArrayCollection" bit is doing.
Regards,
Dave.
I had similar problems my first attempt :)Try this:public function resultHandler(event:ResultEvent):void
{
companyInfo = new ArrayCollection(event.result);
}Shan
From: [email protected] [mailto:[email protected]] On Behalf Of michrx7
Sent: Monday, July 24, 2006 4:17 PM
To: [email protected]
Subject: [Junk E-Mail - LOW] [flexcoders] Returning query results to flex from CFCI 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.
--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.3/395 - Release Date: 7/21/2006
--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.10.3/395 - Release Date: 7/21/2006
__._,_.___
--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com
| Web site design development | Computer software development | Software design and development |
| Macromedia flex | Software development best practice |
YAHOO! GROUPS LINKS
- Visit your group "flexcoders" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

