Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I am having trouble parsing out the struct as array collections in flex

Enthusiast ,
Aug 28, 2008 Aug 28, 2008
I have a function that returns a struct:

<cffunction name="getChartData" access="remote" returntype="struct">
<cfargument name="userID" required="true" type="numeric">
<cfquery name="chart" datasource="#datasource#">
select *
from data where userID = <cfqueryparam value="#arguments.userID#" cfsqltype="cf_sql_integer">
</cfquery>
<cfquery name="comments" datasource="#datasource#">
select comment,dateAdded
from comments where userID = <cfqueryparam value="#arguments.userID#" cfsqltype="cf_sql_integer">
</cfquery>
<cfset struct.chart = chart>
<cfset struct.comments = comments>
<cfset flash.result = struct>
<cfreturn flash.result>
</cffunction>

I am having trouble parsing out the struct as array collections in flex as follows:

private function handleChartData(event:ResultEvent):void{

var fullArray:ArrayCollection = event.result.chart as ArrayCollection ;

comments.dataProvider = event.result.comments as ArrayCollection ;
debug.dataProvider = fullArray;

}

Is there anything that I am doing wrong?
TOPICS
Database access
481
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 28, 2008 Aug 28, 2008
nikos101 wrote:
> I have a function that returns a struct:

which, unless you create a specific class for it, flex side will map as an Object.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 29, 2008 Aug 29, 2008
So in the above example I expect the flex object the struct maps to client side contains two array collections:

struct
{chart ,comments}

How to I access these values without creating a specific class?
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Aug 29, 2008 Aug 29, 2008
nikos101 wrote:
> So in the above example I expect the flex object the struct maps to client side
> contains two array collections:
>
> struct
> {chart ,comments}

it should.

> How to I access these values without creating a specific class?


private function handleChartData(event:ResultEvent):void{
comments.dataProvider = event.result.comments as ArrayCollection ;
}

might be Array instead of ArrayCollection. also watch out for CAsE coming from cf.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 29, 2008 Aug 29, 2008

might be Array instead of ArrayCollection. also watch out for CAsE coming from cf.

It should be an ArrayCollection becase there are multiple column in the table being queried.
I still am not getting anything showing up on my charts when i do

comments.dataProvider = event.result.comments as ArrayCollection ;

However when I don't return a stuct as shown below my datagrid works fine:

<cffunction name="getChartData" access="remote" returntype="query">
<cfargument name="userID" required="true" type="numeric">

<cfquery name="chart" datasource="#datasource#">
select *
from staff_charts_data where userID = <cfqueryparam value="#arguments.userID#" cfsqltype="cf_sql_integer">
</cfquery>


<cfquery name="comments" datasource="#datasource#">
select comment,dateAdded
from staff_charts_comments where userID = <cfqueryparam value="#arguments.userID#" cfsqltype="cf_sql_integer">
</cfquery>

<cfset flash.result = comments>
<cfreturn flash.result>
</cffunction>


comments.dataProvider = event.result as ArrayCollection ;

btw Thanks very much for your gelp so far Paul :)
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Enthusiast ,
Aug 29, 2008 Aug 29, 2008
LATEST
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources