3 Replies Latest reply on Apr 13, 2009 12:51 PM by Jed Schneider

    AdvancedDataGrid, subsort logic?

    Jed Schneider Level 1
      ColumnA has numeric data (from 10 to 99)
      ColumnB has numeric data (from 10 to 99)

      When selecting the header for columnA, it sorts in proper numeric order

      When identifying column B as the secondary sort column (a #2 appears in the header) it does not keep the data from columnA sorted, so for example if there are many values of 40 in columnA, columnB subsorted does not keep the 40's together and then sort the 40's by value in columnB.

      If columnB is a subset of columnA data, eg, the data is hierarchical, it seems to subsort correctly. see example below.

      does not sort right
      <root>
      <item>
      <columnAdata></columnAdata>
      <columbBdata></columnBdata>
      </item>
      <item>
      <columnAdata></columnAdata>
      <columbBdata></columnBdata>
      </item>
      <root>

      does sort right
      <root>
      <columnAdata>
      <columbBdata></columnBdata>
      <columbBdata></columnBdata>
      </columnAdata>
      <columnAdata>
      <columbBdata></columnBdata>
      <columbBdata></columnBdata>
      </columnAdata>
      </root>


      Am I crazy or does the ADG not support subsorting except on hierarchical data?
        • 2. Re: AdvancedDataGrid, subsort logic?
          _Natasha_ Level 4
          Cann't reproduce your problem. All is correct.


          • 3. Re: AdvancedDataGrid, subsort logic?
            Jed Schneider Level 1

            I finally tracked down the subsort issue using the advancedDataGrid.

             

            Warning, warning, to those of you using ADG and XML.

             

            XML

            1. treats all values as Strings
            2. sorts infinitly slower than and arrayCollection of the same size, even if sorting strings

             

            The reason my example was not sorting correctly was that it was trying to do a string sort on subsorts instead of treating the numeric data as numeric data. My solution was to take the xml values, cast them into the correct data types, then add them to an arrayCollection to populate the dataGrid.


            var myAC;ArrayCollection = new ArrayCollection();

            var num:Number;


            private function resultHandler(event:ResultEvent):void

            {

            for each (var eachItem:XML in event.result.myXML)

            {

                 num = Number(eachItem.numberData);


                 ac.addItem( { numberData: num } );

            }


            myAdg.dataProvider = myAC;

            }

            //end script


            <mx:AdvancedDataGrid id="myAdg">

                 <mx:columns>

                      <AdvancedDataGridColumn dataField="numberData"/>

                 </mx:columns>

            </mx:AdvancedDataGrid>