Frank--the code I posted was just a snippet from one of our projects.
It is not intended to work in your particular scenario. You more than
likely do not have a configVO class (if you are a beginner, you
probably are not even using the VO pattern). Furthermore, if your
data is not XML-based (e.g. you are using Webservices or Remoting),
this solution may not even apply.
But, assuming you are using xml-based data:
private function getResult( event:ResultEvent):void {
var dp:ArrayCollection;
//somehow determine if you have only one row by introspecting
data--this will be specific to your situation
if( <one row test comes here...> ) {
dp = new ArrayCollection();
db.add( event.results as ObjectProxy );
} else {
//mult rows in result set
db = event as ArrayCollection;
}
}
On Thu, Mar 12, 2009 at 10:21 AM, Frank Griffin <[email protected]> wrote:
> Scott,
>
> Ok, I am just learning Flex so I need a little more help with this.
>
> Here is where I get the data:
>
> private function getResult(event:ResultEvent):void{
> dataCollection2 =
> event.result.filters.filter as
> ArrayCollection;
> }
>
> So what I need to add is the following:
>
> //if there are more than one param, we already have an
> array collection
> if( configVO.configXML.filters.filter is ArrayCollection
> ) {
> aParam = configVO.configXML.filters.filter
> } else if(
> configVO.configXML.filters.filter is ObjectProxy
> ){
> //only one param--create array collection
> aParam = new ArrayCollection();
> aParam.addItem(
> configVO.configXML.filters.filter );
> }
>
> Is this correct?
>
> Thanks,
>
> Frank
>
>
> -----Original Message-----
> From: [email protected] [mailto:[email protected]] On Behalf Of Scott Talsma
> Sent: Thursday, March 12, 2009 9:56 AM
> To: [email protected]
> Subject: Re: [AFFUG Discuss] DataGrid and array with only one record
>
> If you are pulling in data from a server (particularly xml data), flex
> converts what you need to be an ArrayCollection into an ObjectProxy
> instead. I always try to put a deserialization layer between where I
> get the data an where I use it.
>
>
> //if there are more than one
> param, we already have an array collection
> if(
> configVO.configXML.parameters.parameter is ArrayCollection ) {
> aParam =
> configVO.configXML.parameters.parameter
> } else if(
> configVO.configXML.parameters.parameter is ObjectProxy ){
> //only one param--create
> array collection
> aParam = new
> ArrayCollection();
> aParam.addItem(
> configVO.configXML.parameters.parameter );
> }
>
>
>
> On Thu, Mar 12, 2009 at 9:43 AM, Frank Griffin <[email protected]>
> wrote:
>> Good Morning,
>>
>>
>>
>> I have an array that is the dataProvider to a DataGrid and under all
> but one
>> circumstance all is well. Where I am having a problem is where there
> is only
>> one record in the array. If there are at least two records both appear
> in
>> the DataGrid but if there is only one record no data appears in the
>> DataGrid.
>>
>>
>>
>> Can someone point me to the documentation and or an example of where
> this is
>> handled?
>>
>>
>>
>>
>>
>> Thanks!
>>
>>
>>
>> Frank
>>
>> -------------------------------------------------------------
>> To unsubscribe from this list, simply email the list with unsubscribe
> in the
>> subject line
>>
>> For more info, see http://www.affug.com
>> Archive @ http://www.mail-archive.com/discussion%40affug.com/
>> List hosted by FusionLink
>> -------------------------------------------------------------
>
>
>
> --
> Scott Talsma
> CTO, echoEleven
>
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe in
> the subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by http://www.fusionlink.com
> -------------------------------------------------------------
>
>
>
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe in the
> subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by http://www.fusionlink.com
> -------------------------------------------------------------
>
>
>
--
Scott Talsma
CTO, echoEleven
-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the
subject line
For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------