Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

returning query from cfc

Avatar

Level 1
is it possible to return query data from a cfc back to flex
using the following :



<cffunction name="getClientJobsQuery" access="remote"
returntype="query">

<cfset myQuery="">

<cfquery name="myQuery" datasource="flexTrainingData">

SELECT projectID, projectName, description, contributor

FROM projects

</cfquery>

<cfreturn myQuery>

</cffunction>



i can't seem to get the data to display into a datagrid. I've
tested the query on a normal page and it does work, and just to be
sure the component is actually being reached i added another method
that passes a simple string back - and does so successfully so no
drama there. This is how i pass recordSets back to flash, is it the
same for flex based remoting ?



my code on the flex end is:



<mx:Button label="get Query Remote Object"
click="myService.getClientJobsQuery()"/>

<mx:DataGrid dataProvider="{qResult}">

<mx:columns>

<mx:Array>

<mx:DataGridColumn dataField="project number"/>

<mx:DataGridColumn dataField="project name"/>

<mx:DataGridColumn dataField="description"/>

<mx:DataGridColumn dataField="contributor"/>

</mx:Array>

</mx:columns>

</mx:DataGrid>



Any help greatly appreciated, i'm keen to get into flex
:)
1 Accepted Solution

Avatar

Correct answer by
Level 1
Hi .. i actually got it working yesterday and hadn't had a
chance to post yet ..



i had :



[Bindable]

public var qResult:ArrayCollection;



i just needed to add the following to get it to work:



public function clearAll():void{

qResult=new ArrayCollection();

}



Cheers,

Mark

View solution in original post

2 Replies

Avatar

Level 3
what are you populating qResult with? Can you post the rest
of the flex code?

Avatar

Correct answer by
Level 1
Hi .. i actually got it working yesterday and hadn't had a
chance to post yet ..



i had :



[Bindable]

public var qResult:ArrayCollection;



i just needed to add the following to get it to work:



public function clearAll():void{

qResult=new ArrayCollection();

}



Cheers,

Mark