4 Replies Latest reply on Nov 7, 2008 4:10 PM by Handycam

    Multiple Column Sorting

    Handycam Level 1
      I am trying to sort a datagrid of employees first by city, then by name -- so that within ach city the people are in alpha order.

      I am using this function for the grid:
      private function dataHandler(e:ResultEvent):void {
      var dp:XML = new XML(e.result);
      xmlListColl = new XMLListCollection(dp.employee);
      var sort:Sort = new Sort();
      sort.fields = [new SortField("@city"), new SortField("xmlListColl.@name")];
      xmlListColl.sort = sort;

      It works fine with just the first SortField; the second one seems to do nothing.

      Am I misunderstanding?

      The datagrid is:

      <mx:DataGrid id="people" dataProvider="{xmlListColl}" width="100%" height="100%" fontSize="10">
      <mx:DataGridColumn dataField="@city" headerText="City" />
      <mx:DataGridColumn dataField="@state" headerText="" width="25" />
      <mx:DataGridColumn dataField="@name" headerText="Name" />
      <mx:DataGridColumn dataField="@dept" headerText="Department"/>
      <mx:DataGridColumn dataField="@phone" headerText="Phone" width="50"/>