4 Replies Latest reply on Mar 13, 2007 2:25 PM by phi2265

    Sorting a tileList or horizontalList

    phi2265 Level 1
      Is there a way to sort a tileList or horizontalList backwards? Also, do itemRenderers work the same in a dataGrid as they do in a tileList? I'm thinking I might have to use a dataGrid instead of a tileList.. but I really don't want to do that. Thanks...

        • 1. Re: Sorting a tileList or horizontalList
          peterent Level 2
          If you want to sort in reverse create a Sort object and set the SortField to sort in descending order. Then add the Sort object to the collection's sort property. After you've done that invoke the Collection's refresh() function. That will kick off the Sort. From then on, until you change the sort or remove it, every action on the Collection will be sorted.

          itemRenderers work the same on all the List classes.
          • 2. Re: Sorting a tileList or horizontalList
            phi2265 Level 1
            If only I could figure out how to load my external XML document to a variable... this has been eluding me for some time...

            I've tried putting result="resultFunction(event)" in my HTTPService..

            public function resultFunction(event:ResultEvent):void{
            articleXML = XML(event.result);

            and then I would bind articleXML to my tileList as the dataProvider.. but for some reason the result I get is HTML and not the XML document specified in my HTTPService.

            I'm having a really hard time figuring this out...

            and to top it off.. no matter what I change the name of my XML document to, the old cached XML document is loaded. It just wont update. I have method="POST"... nothing is going right for me tonight...

            • 3. Re: Sorting a tileList or horizontalList
              phi2265 Level 1
              Alright, ignore that last post.. I figured it out. With e4x formatting you dont reference the top node, <articles> in my case. So I did articleXML.article, instead of articleXML.articles.article.

              So right now what I can't figure out is how to get my XML into some type of Collection so that I can sort it. Suggestions anyone?

              • 4. Sorting a tileList or horizontalList
                phi2265 Level 1
                Got it... thanks for the pointer Peter

                import mx.rpc.events.ResultEvent;

                public var archiveXML:XML;
                public var sort:Sort = new Sort();

                public function archiveXMLResult(event:ResultEvent):void{
                archiveXML = XML(event.result);

                public function sortArchiveXML():void{
                sort.fields = [new SortField("name", true, true)]; //by name, caseInsensitive, descending
                archiveXMLCol.sort = sort;

                <mx:HTTPService id="articleSrv" url="articles.xml?{appendNum}" method="POST" showBusyCursor="true" resultFormat="e4x" result="archiveXMLResult(event);"/>
                <mx:XMLListCollection id="archiveXMLCol" source="{archiveXML.article}"/>
                tileList dataProvider="{archiveXMLCol}"