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.