3 Replies Latest reply on Dec 28, 2008 10:14 AM by Newsgroup_User

    AdvancedDataGrid as Tree

    John Hall Level 4
      OK. I give up. After a few days of trying lots of different approaches (hierarchicalData, HierarchicalCollectionView, GroupingCollections, mxml dataproviders, etc), I have yet to hit on the right combination to accomplish what is probably an easy task. I'll explain where I'm at in this incarnation (yes, I've been through Amy's examples several times but something is just not clicking). Gosh, I figured moving from a Tree to the ADG would be pretty simple.

      OK, the code that will not alphabetize the final node without including a folder:
        • 1. Re: AdvancedDataGrid as Tree
          Level 7

          "John Hall" <webforumsuser@macromedia.com> wrote in message
          news:girtjs$dlv$1@forums.macromedia.com...
          > OK. I give up. After a few days of trying lots of different approaches
          > (hierarchicalData, HierarchicalCollectionView, GroupingCollections, mxml
          > dataproviders, etc), I have yet to hit on the right combination to
          > accomplish
          > what is probably an easy task. I'll explain where I'm at in this
          > incarnation
          > (yes, I've been through Amy's examples several times but something is just
          > not
          > clicking). Gosh, I figured moving from a Tree to the ADG would be pretty
          > simple.
          >
          > OK, the code that will not alphabetize the final node without including a
          > folder:
          >
          > I retrieve an arrayCollection from ColdFusion. Everything is sorted fine
          > here
          > and there's no problem seeing the data sequentially upon trace:
          >
          > public function handleGetCurrentData(e:ArrayCollection):void{
          > var courseNameGroup:Grouping = new Grouping();
          > courseNameGroup.fields = [new GroupingField("moduleLabel"),new
          > GroupingField("questionLabel")];
          > var myGC:GroupingCollection = new GroupingCollection();
          > myGC.source = e;
          > myGC.grouping = courseNameGroup;
          > myGC.refresh();
          > acDP = myGC;
          > }
          >
          > In the app's current incarnation (what I refer to as v_74), I use acDP
          > (another grouping collection in a different component) as the dataProvider
          > for
          > the ADG:
          >
          > <mx:AdvancedDataGrid click="changeEvt(event)"
          > preinitialize="getModuleInfo()" id="browserTree"
          > x="10" y="10" designViewDataType="tree"
          > width="220" dataProvider="{acDP}"
          > color="#000000">
          >
          > <mx:columns>
          > <mx:AdvancedDataGridColumn headerText="Modules" sortable="true"
          > dataField="answerLabel" sortDescending="false" />
          > </mx:columns>
          > </mx:AdvancedDataGrid>
          >
          > It all works fine except the final leafs are not sorted:
          >
          > [folder] Module 1
          > [folder] Question 1
          > [leaf] Answer 3
          > [leaf] Answer 1
          > [leaf] Answer 2
          > [leaf] Answer 4
          >
          >
          > Everything is sorted in the arraycollection coming in and I can solve the
          > problem by adding new GroupingField("answerLabel") in the original
          > coursNameGroup.fields
          >
          > courseNameGroup.fields = [new GroupingField("moduleLabel"),new
          > GroupingField("questionLabel"),new GroupingField("answerLabel")];
          >
          > but that adds a superfluous folder. Suggestions?

          You need to add a compareFunction. For some reason, GroupingCollection
          screws up the sorting. You'll probably need to sort on your distractor order
          field from the database.

          HTH;

          Amy


          • 2. Re: AdvancedDataGrid as Tree
            John Hall Level 4
            Took a couple days to experiment with grouping, sorting, comparefunctions etc and have a much better handle on things. Comparefunction worked great was so easy it was confusing. At first, looking at its signature, it looked like one had to pass in two parameters but I finally got it and it makes life much easier. Thanks Amy.
            • 3. Re: AdvancedDataGrid as Tree
              Level 7

              "John Hall" <webforumsuser@macromedia.com> wrote in message
              news:gj8clu$nhv$1@forums.macromedia.com...
              > Took a couple days to experiment with grouping, sorting, comparefunctions
              > etc
              > and have a much better handle on things. Comparefunction worked great was
              > so
              > easy it was confusing. At first, looking at its signature, it looked like
              > one
              > had to pass in two parameters but I finally got it and it makes life much
              > easier. Thanks Amy.

              You're welcome :-)

              I probably spent two work days' worth of "down time" writing the
              GroupingFunction example because some of the stuff is a little unintuitive.

              -Amy