7 Replies Latest reply on Nov 1, 2008 5:03 PM by Mark.P.

    What am I doing wrong with my GroupingCollection

    Mark.P.
      I have an AdvancedDataGrid where I'm trything to display the data in
      groups. The column order is as follows -- Person Name, Project,
      Date, and a few numbered data columns. I'm tring to sort my data in
      the order of my columns, Name, Project, Date.

      In my ADG it looks good but the date is not sorted. I used a sort
      on my ArrayCollection but that didn't do anything to help and when I
      add another GroupingField for month it just splits it up more than I
      want.

      The GroupingCollection sorts the Project and Name, but what can I do
      sort the date?

      Thanks,
      Mark
        • 1. Re: What am I doing wrong with my GroupingCollection
          Level 7

          "Mark.P." <mark.pusateri@ey.com> wrote in message
          news:ge7svv$cro$1@forums.macromedia.com...
          >I have an AdvancedDataGrid where I'm trything to display the data in
          > groups. The column order is as follows -- Person Name, Project,
          > Date, and a few numbered data columns. I'm tring to sort my data in
          > the order of my columns, Name, Project, Date.
          >
          > In my ADG it looks good but the date is not sorted. I used a sort
          > on my ArrayCollection but that didn't do anything to help and when I
          > add another GroupingField for month it just splits it up more than I
          > want.

          You have to do a sort on the groupingField or else it somehow can't
          determine which dates should be earlier. See this example:
          http://www.magnoliamultimedia.com/flex_examples/GroupingFunction


          • 2. Re: What am I doing wrong with my GroupingCollection
            Mark.P. Level 1
            Thanks Amy.. that mostly did it but I'm sure I did it wrong because it changed the layout within the ADG. I added a new GroupingField for the date which includes the compareFunction...

            <mx:GroupingField name="month" compareFunction="getMonth"/>

            ...but the Advanced DataGrid now shows the month in the first column along with the expandable Person Name and Project Name. What do I need to do in order for the ADG to show the projects in order of the date but not be part of that first column with it's own twistee?
            • 3. Re: What am I doing wrong with my GroupingCollection
              Level 7

              "Mark.P." <mark.pusateri@ey.com> wrote in message
              news:ge899p$so4$1@forums.macromedia.com...
              > Thanks Amy.. that mostly did it but I'm sure I did it wrong because it
              > changed
              > the layout within the ADG. I added a new GroupingField for the date which
              > includes the compareFunction...
              >
              > <mx:GroupingField name="month" compareFunction="getMonth"/>
              >
              > ...but the Advanced DataGrid now shows the month in the first column along
              > with the expandable Person Name and Project Name. What do I need to do in
              > order for the ADG to show the projects in order of the date but not be
              > part of
              > that first column with it's own twistee?
              >
              > <mx:GroupingCollection id="gcPerson" source="{myData2}" >
              > <mx:grouping>
              > <mx:Grouping>
              > <mx:GroupingField name="name"/>
              > <mx:GroupingField name="title">
              > <mx:SummaryRow summaryPlacement="group">
              > <mx:fields>
              > <mx:SummaryField operation="COUNT" dataField="title"/>
              > </mx:fields>
              > </mx:SummaryRow>
              > <mx:SummaryRow summaryPlacement="last">
              > <mx:fields>
              > <mx:SummaryField operation="SUM" dataField="projectedHours"
              > label="summaryPro" />
              > <mx:SummaryField operation="SUM" dataField="actualHours"
              > label="summary" />
              > </mx:fields>
              > </mx:SummaryRow>
              > </mx:GroupingField>
              > <mx:GroupingField name="month" compareFunction="getMonth"/>
              > </mx:Grouping>
              > </mx:grouping>
              > </mx:GroupingCollection>

              If you don't want a GroupingField on Month, try instead adding a sort to the
              Grouping that contains the field. BTW, I have no idea what a twistee is :-)

              HTH;

              Amy


              • 4. Re: What am I doing wrong with my GroupingCollection
                Mark.P. Level 1
                I guess after working at the same place for so long you use the corporate terminology and forget no one else uses it. Twistee “>” in this case is the disclosure open/close icon. :-)

                I’ve added the compareFunction in just about every place it can be, each will NOT give me the desired result. Here’s what it should be -- The first column should be Person’s Name > Project Name > Person’s Name for each date entry for that project. Column two is the project name, column 3 is the date, etc. I also added the XML this time.

                This GroupingCollection set up (without compareFunction) gives me the proper layout of the ADG but the projects are not in order of their date:

                <mx:GroupingCollection id="gcPerson" source="{myData2}" >
                <mx:grouping>
                <mx:Grouping>
                <mx:GroupingField name="name"/>
                <mx:GroupingField name="title" >
                <mx:SummaryRow summaryPlacement="group">
                <mx:fields>
                <mx:SummaryField operation="COUNT" dataField="title" />
                </mx:fields>
                </mx:SummaryRow>
                <mx:SummaryRow summaryPlacement="last">
                <mx:fields>
                <mx:SummaryField operation="SUM" dataField="projectedHours" label="summaryPro" />
                <mx:SummaryField operation="SUM" dataField="actualHours" label="summary" />
                </mx:fields>
                </mx:SummaryRow>
                </mx:GroupingField>
                </mx:Grouping>
                </mx:grouping>
                </mx:GroupingCollection>

                Here with the compareFucntion added to the GroupingField on title (project title) it lays out the first column -- Person’s Name, under that are all the projects listed for each date. So it will list the project name each time it’s listed in the XML with a new date.

                <mx:GroupingCollection id="gcPerson" source="{myData2}" >
                <mx:grouping>
                <mx:Grouping>
                <mx:GroupingField name="name"/>
                <mx:GroupingField name="title" compareFunction=”getMonth”>
                <mx:SummaryRow summaryPlacement="group">
                <mx:fields>
                <mx:SummaryField operation="COUNT" dataField="title" />
                </mx:fields>
                </mx:SummaryRow>
                <mx:SummaryRow summaryPlacement="last">
                <mx:fields>
                <mx:SummaryField operation="SUM" dataField="projectedHours" label="summaryPro" />
                <mx:SummaryField operation="SUM" dataField="actualHours" label="summary" />
                </mx:fields>
                </mx:SummaryRow>
                </mx:GroupingField>
                </mx:Grouping>
                </mx:grouping>
                </mx:GroupingCollection>

                And my last try, which is getting close like #1, but adds a new layer to the first column. So this one now has the Person’s Name > Project Name (listed only once per project (good)) > New Level with each ordered by date.

                <mx:GroupingCollection id="gcPerson" source="{myData2}" >
                <mx:grouping>
                <mx:Grouping>
                <mx:GroupingField name="name"/>
                <mx:GroupingField name="title">
                <mx:SummaryRow summaryPlacement="group">
                <mx:fields>
                <mx:SummaryField operation="COUNT" dataField="title" />
                </mx:fields>
                </mx:SummaryRow>
                <mx:SummaryRow summaryPlacement="last">
                <mx:fields>
                <mx:SummaryField operation="SUM" dataField="projectedHours" label="summaryPro" />
                <mx:SummaryField operation="SUM" dataField="actualHours" label="summary" />
                </mx:fields>
                </mx:SummaryRow>
                </mx:GroupingField>
                <mx:GroupingField groupingFunction=”getLabel” compareFucntion=”getMonth”/>
                </mx:Grouping>
                </mx:grouping>
                </mx:GroupingCollection>

                • 5. Re: What am I doing wrong with my GroupingCollection
                  Level 7

                  "Mark.P." <mark.pusateri@ey.com> wrote in message
                  news:ge9t3g$92u$1@forums.macromedia.com...
                  >I guess after working at the same place for so long you use the corporate
                  > terminology and forget no one else uses it. Twistee ?>? in this case is
                  > the
                  > disclosure open/close icon. :-)
                  >
                  > I?ve added the compareFunction in just about every place it can be, each
                  > will
                  > NOT give me the desired result. Here?s what it should be -- The first
                  > column
                  > should be Person?s Name > Project Name > Person?s Name for each date entry
                  > for
                  > that project. Column two is the project name, column 3 is the date, etc.
                  > I
                  > also added the XML this time.
                  >
                  > This GroupingCollection set up (without compareFunction) gives me the
                  > proper
                  > layout of the ADG but the projects are not in order of their date:

                  Have you thought about having the compareFunction and/or sortFunction at the
                  lowest level you want to group by compare both the name and the date?


                  • 7. Re: What am I doing wrong with my GroupingCollection
                    Mark.P. Level 1
                    Boy.. I hate to keep bringing this up but I just can NOT, for the life of me, figure out why this will not sort. Now I took one of the ADG and GroupingCollection samples from the Flex Help files and added a basic sort and even that won't sort. I'd really like someone to look at this code and let me know what the heck is wrong?