0 Replies Latest reply on Mar 3, 2008 3:20 PM by ericbelair

    Sort by two columns in Grouping Collection

    ericbelair Level 1
      I have an Array Collection like so:

      <mx:ArrayCollection id="stateArray">
      <mx:Object state="CT" city="Hartford" stateDisplayCode="1" cityDisplayCode="1" />
      <mx:Object state="CT" city="Springfield" stateDisplayCode="1" cityDisplayCode="10" />
      <mx:Object state="CT" city="New Haven" stateDisplayCode="1" cityDisplayCode="12" />
      <mx:Object state="AL" city="Montgomery" stateDisplayCode="2" cityDisplayCode="2" />
      <mx:Object state="AL" city="Springfield" stateDisplayCode="2" cityDisplayCode="5" />
      <mx:Object state="AL" city="Anytown" stateDisplayCode="2" cityDisplayCode="10" />
      <mx:Object state="AK" city="Juneau" stateDisplayCode="3" cityDisplayCode="3" />
      <mx:Object state="AK" city="Valdez" stateDisplayCode="3" cityDisplayCode="4" />
      </mx:ArrayCollection>

      I am using this as the source for a Grouping Collection in an AdvancedDataGrid:

      <mx:AdvancedDataGrid id="advancedDataGrid" width="100%" height="100%" >
      <mx:dataProvider>
      <mx:GroupingCollection id="groupingCollection" source="{stateArray}">
      <mx:grouping>
      <mx:Grouping>
      <mx:GroupingField name="state" />
      </mx:Grouping>
      </mx:grouping>
      </mx:GroupingCollection>
      </mx:dataProvider>
      <mx:columns>
      <mx:AdvancedDataGridColumn dataField="city" />
      </mx:columns>
      </mx:AdvancedDataGrid>

      I'm basically creating an Advanced Data Grid grouped by State and City and I want to sort on the stateDisplayCode field FIRST, and then the cityDisplayCode field. Can anyone help? I've tried a compareFunction onthe Grouping Field, but this will only sort one field.