Don't know if this is exactly what you are asking for, but this is
another way to determine the number of results:

private function handleNewProductsResult(evt:ResultEvent):void {
   if (evt.result.products == null) {
      // there are no results
      newProductCount = 0;
   }
   else if (evt.result.products.product[0] == null) {
      // not an array, so there is only one result
      // and the result is evt.result.products.product
      newProductCount = 1;
   } 
   else {
      // is an array with more than 1 result
      newProductCount = evt.result.products.product.length;
   }
   //...
}

-David

--- In [email protected], "joshuajnoble" <[EMAIL PROTECTED]> wrote:
>
> 
> Just a suggestion, but try binding your DG to a seperate object and
> then when the onResult comes back, try/catch through it (using
> try{....}catch{....}), so that if there's only one result you're not
> getting unhandled exceptions. You'll be able to get dowwn to the
> length that way. If there are no problems then set your object to
> evt.result.
> You could also just throw it into an array and then count that.
> 
> --- In [email protected], "greenfishinwater"
> <greenfishinwater@> wrote:
> >
> > I am using HTTPService to return a result set, under normal
> > circumstances there will be 100s of records returned, so I determine
> > the total number of records in this way:
> > 
> > This function is called from the result handler of the HTTPService
> > 
> > private function handleNewProductsResult(evt:ResultEvent):void {
> >   newProductCount = evt.result.products.product.length;
> > 
> > But as I discovered if there are no records or only a single record
> > that does not work. So I came up with the following which works:
> > 
> > private function handleNewProductsResult(evt:ResultEvent):void {
> >   if (newProductListDG.dataProvider != null) {
> >     newProductCount = newProductListDG.dataProvider.length;
> >   } else {
> >     newProductCount = 0;
> >   }
> > 
> > newProductListDG is the grid that displays the records and is bound
> > directly to getNewProducts.lastResult.products.product
> > 
> > getNewProducts is the id of the HTTPService
> > 
> > Is there a better way of doing this?
> > 
> > Thanks
> > 
> > Andrew
> >
>









--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/flexcoders/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/flexcoders/join
    (Yahoo! ID required)

<*> To change settings via email:
    mailto:[EMAIL PROTECTED] 
    mailto:[EMAIL PROTECTED]

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to