<p>In a Flex <code>AdvancedDatGrid</code>, 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</p>

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

<pre><code>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]
}      
</code></pre>

<p>The XML:</p>

<pre><code>(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)
</code></pre>

<p><code>OfferID</code>'s work Correctly, <code>OfferDescription</code>s don't.</p>

[{'answer_id': 69156, 'author': 'Raleigh Buckner', 'author_id': 1153, 'author_profile': 'https://Stackoverflow.com/users/1153', 'pm_score': 2, 'selected': True, 'text': '<p>It looks like the summaryFunction has to return a number. According to the <a href="https://bugs.adobe.com/jira/browse/FLEXDOCS-431" rel="nofollow noreferrer">Adobe bug tracker</a>, it is a bug in the documentation:</p>\n\n<blockquote>\n  <p>Comment from Sameer Bhatt:</p>\n  \n  <p>In the documentation it is mentioned that -\n  The built-in summary functions for SUM, MIN, MAX, AVG, and COUNT all return a Number containing the summary data.</p>\n  \n  <p>So people can get an idea but I agree with you that we should clearly mention that the return type should be a Number.</p>\n  \n  <p>We kept it as an Object so that it\'ll be easy in the future to add more things in it.</p>\n</blockquote>\n'}, {'answer_id': 1406545, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>If you need to get a string to show then use the labelfunction on the advancedDataGridColumn.  This will render the summary row.</p>\n\n<p>(mx:AdvancedDataGridColumn headerText="Comment" width="140" dataField="comment" labelFunction="formatColumn" /)</p>\n\n<pre><code>            private function getNestedItem(item:Object):Object {\n\n                try {\n                    if (item.undefined[0]) {\n                        item = getNestedItem(item.undefined[0]);\n                    }\n                } catch (e:Error) {\n                    // leave item alone\n                }\n                return item;\n            }           \n            private function formatColumn(item:Object, column:AdvancedDataGridColumn):String {\n\n                var output:String;\n                // If this is a summary row\n                if (item.GroupLabel) {\n\n                    item = getNestedItem(item);\n                } \n\n                switch (column.dataField) {\n\n                    case \'comment\':\n\n                        return item.comment;\n\n\n                }\n\n            }\n</code></pre>\n'}]
['https://Stackoverflow.com/questions/65627', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/9056/']