2 Replies Latest reply on Apr 22, 2010 4:19 AM by Karthik@Chennai

    Regarding Tree sort

    Karthik@Chennai Level 1

      Hi All,

      How to sort  a tree which contains Multilevel node  XMLList collection as dataprovider.

      Note :I have tried with XMLList collection sort functionality but able to do sorting for first level iam struck child level recursively...

      regards,

      karthik

        • 1. Re: Regarding Tree sort
          Flex harUI Adobe Employee

          There is no support for that in Tree. There is some support in

          AdvancedDataGrid so you can try it there.

          • 2. Re: Regarding Tree sort
            Karthik@Chennai Level 1

            Hi All,

            I have solved the sorting issue by keeping the child items in a separate clone copy as XMLList collection and updated to the original dataprovide by delete and inserting node freshly.For ur reference i have attached the code

             

            private function sortTree(selectedItemNode:XML):void
            {
            var i:int;
            var serverNodeList:XMLList = selectedItemNode.children();   
            var newColl:XMLListCollection = new XMLListCollection(selectedItemNode.children());
            var sortList:Sort = new Sort();

            //this block of codes to remove the childrens of the selected node
            for(i = 0; i < serverNodeList.length(); i++)
            {
              delete serverNodeList[i];
              i--;
              if(serverNodeList[i].children().length() > 0)
              {
               sortTree(serverNodeList[i]);
              }
            }
            sortList.fields=[new SortField("@label", true, false)];
            newColl.sort = sortList;
            newColl.refresh();

            //this block of codes to add the childrens under the selected node
            for(i = 0; i < newColl.length; i++)
            {
              selectedItemNode.appendChild(newColl[i])

            }

             

            regards,

            karthik