apache-flexadvanceddatagrid

Can you return a String from a summaryObjectFunction


In a Flex AdvancedDatGrid, we're doing a lot of grouping. Most of the columns are the same for the parents and for the children, so I'd like to show the first value of the group as the summary rather than the MAX, MIN or AVG

This code works on numerical but not textual values (without the commented line you get NaN's):

private function firstValue(itr:IViewCursor,field:String, str:String=null):Object 
{
  //if(isNaN(itr.current[field])) return 0  //Theory: Only works on Numeric Values?
  return itr.current[field]
}      

The XML:

(mx:GroupingField name="Offer")
  (mx:summaries)
    (mx:SummaryRow summaryPlacement="group")
      (mx:fields)
        (mx:SummaryField dataField="OfferDescription"   label="OfferDescription" summaryFunction="firstValue"/)
        (mx:SummaryField dataField="OfferID"   label="OfferID" summaryFunction="firstValue"/)
        (/mx:fields)
    (/mx:SummaryRow)
  (/mx:summaries)
(/mx:GroupingField)

OfferID's work Correctly, OfferDescriptions don't.


Solution

  • It looks like the summaryFunction has to return a number. According to the Adobe bug tracker, it is a bug in the documentation:

    Comment from Sameer Bhatt:

    In the documentation it is mentioned that - The built-in summary functions for SUM, MIN, MAX, AVG, and COUNT all return a Number containing the summary data.

    So people can get an idea but I agree with you that we should clearly mention that the return type should be a Number.

    We kept it as an Object so that it'll be easy in the future to add more things in it.