Tom

If you post a small runnable example with sample data, I would be willing to 
take a look.


Best Regards




Steve

--- In flexcoders@yahoogroups.com, Tom McNeer <tmcn...@...> wrote:
>
> Hi,
> 
> I posted this issue earlier, but got no replies. I'm really hoping someone
> familiar with ADG oddities can help me out.
> 
> I have an Advanced DataGrid which receives an array collection of sales
> information as a data provider. The data is in a flat grouping, and the only
> GroupingField is "Office," which contains either "Atlanta" or "Dallas" as a
> value. The rest of the data in each "row" of the data provider contains a
> variety of sales statistics for a given month.
> 
> With no compareFunction at all, the ADG correctly groups the records into
> two groups, with Atlanta first. But as expected, the ordering of the records
> within the group doesn't reflect the contents of the original data, i.e.,
> it's not ordered by month.
> 
> However, when I add a compareFunction which compares a SortDate value within
> each object in the array (which is not displayed - it's simply a date
> signifying the first of each month, to provide a sorting mechanism), a
> strange thing happens.
> 
> Instead of two groupings, I have 6. And the ordering of the offices has been
> reversed. So I get Dallas>Atlanta>Dallas>Atlanta>
> Dallas>Atlanta.
> 
> Within each grouping, the records are correctly sorted by descending date
> values. And the groups themselves, when expanded, show that all the records
> in Dallas and Atlanta groups are sorted correctly - but they're broken into
> all those extra groups.
> 
> I have verified that the records coming into the application all have the
> correct values for the Office and SortDate fields, so the problem isn't
> there.
> 
> Here's the ADG:
> 
> <mx:AdvancedDataGrid width="1125" height="265" id="monthlyTotalGrid"
> defaultLeafIcon="{null}" wordWrap="true"
>          variableRowHeight="true" initialize="rc.refresh();"
> selectionColor="#fcffcd" sortableColumns="false" sortExpertMode="true">
>         <mx:dataProvider>
>             <mx:GroupingCollection id="rc" source="{monthlyTotals}">
>                 <mx:grouping>
>                     <mx:Grouping>
>                         <mx:GroupingField name="Office"
> groupingFunction="createGroupLabel" compareFunction="compareDate" />
>                     </mx:Grouping>
>                 </mx:grouping>
>             </mx:GroupingCollection>
>         </mx:dataProvider>
>         <mx:columns>
>             <mx:AdvancedDataGridColumn dataField="Month"
> headerWordWrap="true" width="150" />
>             <mx:AdvancedDataGridColumn dataField="Total Cases"
> headerWordWrap="true" textAlign="center" />
> ... several other columns go here
> 
>         </mx:columns>
>     </mx:AdvancedDataGrid>
> 
> ... and here's my compareFunction:
> 
> private function compareDate(a:Object,b:Object):int{
>             var aTime:Number = a.SortDate.getTime();
>             var bTime:Number = b.SortDate.getTime();
>             if(aTime < bTime){
>                 return 1;
>             }
>             if(aTime>bTime){
>                 return -1;
>             }
>             else return 0;
> 
>         }
> 
> I'm very inexperienced with the ADG, so it's probably something simple I'm
> missing. Any help would be appreciated.
> 
> 
> -- 
> Thanks,
> 
> Tom
> 
> Tom McNeer
> MediumCool
> http://www.mediumcool.com
> 1735 Johnson Road NE
> Atlanta, GA 30306
> 404.589.0560
>


Reply via email to