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]ups.com,
"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]ups.com,
"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
> >
>