The first step for Grouping is to sort on that specific column. and then put the flat data rows into each bucket. Now to achieve your objective of sorting on a non-grouped column First call GC.refresh() --> sorts on grouped column Now u need to set the Gc.dataprovider.sort = new Sort("non-grouped colm here") and then refresh again.
Check out my version of GroupingCollection http://flexingflashing.blogspot.com/ --- In flexcoders@yahoogroups.com, Maciek Sakrejda <msakre...@...> wrote: > > I have an ADG (simplified example that reproduces the issue follows). I > want the data broken down by category, but sorted by value (which is > *not* grouped) within each category. I thought the way to do this would > be to set up a ListCollectionView to sort my data, then put a grouping > collection on top. The GroupingCollection, however, seems to undo the > ListCollectionView sorting. > > Is there a way to achieve this with the AdvancedDataGrid? If I bind > sortedData to a plain DataGrid (with no grouping), this works as > expected. > > Code follows: (note that within each group, things are *not* sorted by > value). > > <?xml version="1.0" encoding="utf-8"?> > <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" > layout="vertical"> > <mx:Script> > <![CDATA[ > import mx.collections.SortField; > import mx.collections.Sort; > import mx.collections.ListCollectionView; > import mx.collections.ArrayCollection; > > public var myData:ArrayCollection = new ArrayCollection([ > { category: 'foo', value: 4 }, > { category: 'foo', value: 3 }, > { category: 'foo', value: 7 }, > { category: 'bar', value: 2 }, > { category: 'bar', value: 1 }, > { category: 'bar', value: 8 }, > ]); > > public var sortedData:ListCollectionView = new > ListCollectionView(myData); > > private function handleAdgInit(e:Event):void { > var valSort:Sort = new Sort(); > valSort.fields = [ new SortField('category'), new > SortField('value', false, false, true) ]; > sortedData.sort = valSort; > sortedData.refresh(); > gc.refresh(); > } > > ]]> > </mx:Script> > <mx:AdvancedDataGrid id="myADG" > width="100%" height="100%" allowMultipleSelection="true" > initialize="handleAdgInit(event)"> > <mx:dataProvider> > <mx:GroupingCollection id="gc" source="{sortedData}"> > <mx:grouping> > <mx:Grouping> > <mx:GroupingField name="category"/> > </mx:Grouping> > </mx:grouping> > </mx:GroupingCollection> > </mx:dataProvider> > > <mx:columns> > <mx:AdvancedDataGridColumn dataField="category"/> > <mx:AdvancedDataGridColumn dataField="value"/> > </mx:columns> > </mx:AdvancedDataGrid> > </mx:Application> > > -- > Maciek Sakrejda > Truviso, Inc. > http://www.truviso.com >