8 Replies Latest reply on Nov 10, 2008 5:18 AM by Mark.P.

    AdvancedDataGrid/GroupingCollection and Sort

    Vesta0424
      Hello!

      I swear this should be easy, but .... any help greatly appreciated.

      I am binding an ArrayCollection to a GroupingCollection and then binding the GroupingCollection to an Advanced Data Grid. I use a function to sort the ArrayCollection. WhenI look at the ArrayCollection variable in debugging, it IS sorted. However, the results in the AdvancedDataGrid are not showing as sorted by the name filed as specified in the sort.

      Oh wise Flex experts, what am I missing?

      Code Attached.

      Thanks in advance for any help proferred.

      Georgia


        • 1. Re: AdvancedDataGrid/GroupingCollection and Sort
          Level 7

          "Vesta0424" <webforumsuser@macromedia.com> wrote in message
          news:ge57u7$heh$1@forums.macromedia.com...
          > Hello!
          >
          > I swear this should be easy, but .... any help greatly appreciated.
          >
          > I am binding an ArrayCollection to a GroupingCollection and then binding
          > the
          > GroupingCollection to an Advanced Data Grid. I use a function to sort the
          > ArrayCollection. WhenI look at the ArrayCollection variable in debugging,
          > it
          > IS sorted. However, the results in the AdvancedDataGrid are not showing
          > as
          > sorted by the name filed as specified in the sort.
          >
          > Oh wise Flex experts, what am I missing?

          Try sorting the GroupingCollection GroupingField...


          • 2. Re: AdvancedDataGrid/GroupingCollection and Sort
            Vesta0424 Level 1
            Hi, sorry, but this response is a bit cryptic for a newbie. How would I do this?

            I don't seem to be the only one that has this problem. In fact a search has turned up many questions about this, but no answers that seem to have a viable solution.

            It would be in Adobe's best interest to provide cookbook recipe type solutions to problems like these, which can be a big pain for someone who doesn't know what s/he is doing. Mucking around for 6 hours to do a simple sort like this is counter-productive.

            Thanks,

            Georgia

            • 3. Re: AdvancedDataGrid/GroupingCollection and Sort
              Level 7

              "Vesta0424" <webforumsuser@macromedia.com> wrote in message
              news:ge75ji$9te$1@forums.macromedia.com...
              > Hi, sorry, but this response is a bit cryptic for a newbie. How would I
              > do
              > this?
              >
              > I don't seem to be the only one that has this problem. In fact a search
              > has
              > turned up many questions about this, but no answers that seem to have a
              > viable
              > solution.
              >
              > It would be in Adobe's best interest to provide cookbook recipe type
              > solutions
              > to problems like these, which can be a big pain for someone who doesn't
              > know
              > what s/he is doing. Mucking around for 6 hours to do a simple sort like
              > this
              > is counter-productive.

              There's an example of how to do this on my blog, though it doesn't use an
              AdvancedDataGrid
              http://flexdiary.blogspot.com/2008/09/groupingcollection-example-featuring.html


              • 4. AdvancedDataGrid/GroupingCollection and Sort
                m_hartnett Level 3
                Georgia,

                You need to put empGC.refresh(); after the sortEmps() call.

                empGC is a collection just like the the ArrayCollection that holds your data.
                All collections need to be refreshed after a filter or sort.

                Dont get too frustrated with Flex. There is a bit of learning curve but eventually you will see that there are a lot of common threads in the way things are done with the objects.

                Good Luck
                • 5. Re: AdvancedDataGrid/GroupingCollection and Sort
                  Vesta0424 Level 1
                  Thanks, whoever you are, who told me to refresh my groupingcollection source. That worked. Before reading this, I also tried Amy's suggestion, to use a comparefunction. That worked as well, but your suggestion is so much more intuitive (and easy). I would guess a compareFunction would be useful if you had to do a more complex sort.

                  Thanks again.
                  • 6. Re: AdvancedDataGrid/GroupingCollection and Sort
                    Mark.P.
                    I have been having the exact same issue for a while now and I just can't get it to work, even with the refresh(). Can someone, maybe an AdvancedDataGrid expert, help me out with this? All I'm trying to achieve here is getting the group (gcPerson) to sort projects by date while showing in the ADG as Name dropdown to Project.
                    • 7. Re: AdvancedDataGrid/GroupingCollection and Sort
                      m_hartnett Level 3
                      MarkP,

                      I dont know if you are still having issues here but I believe that since your xml sort fields are attributes and not elements all your sort conditions need to have an @ (such as @month) in order to sort them.

                      I am not sure that addresses your problem.
                      • 8. Re: AdvancedDataGrid/GroupingCollection and Sort
                        Mark.P. Level 1
                        Thanks but I had to create the goupingCollections with AS in order to get it to work properly. I'm not sure why the sorting doens't work in the ADG if you create the groups in mxml, but I'd be interested to find out. Maybe an Adobe expert can let us know, or what additional step needs to be done.

                        Mark