1 Reply Latest reply on Sep 2, 2008 7:06 PM by Newsgroup_User

    AdvancedDatagrid grouping

    Stef_Dev
      I have troubles understanding how to use the grouping feature of an
      advancedDatagrid.

      How do you group on field1 BUT display field2 as the label of the group ?

      Here's my code :
      var grpField:GroupingField = new GroupingField;
      grpField.name = "field1"; // group on field1
      grpField.groupingFunction = groupFunc;

      private function groupFunc(item:Object, field:GroupingField):String
      {
      // display field2 as the label of the group
      return item.field2;
      }

      Result : He actually groups on field2, ignoring totally field1.
      the documentation says that groupingFunction is "A function that
      determines the label for this group", and not a function who is
      supposed to influence the grouping.

      Help me, I'm kind of lost :)

      Thanks in advance
        • 1. Re: AdvancedDatagrid grouping
          Level 7

          "Stef_Dev" <webforumsuser@macromedia.com> wrote in message
          news:g9giii$2ss$1@forums.macromedia.com...
          >I have troubles understanding how to use the grouping feature of an
          > advancedDatagrid.
          >
          > How do you group on field1 BUT display field2 as the label of the group ?
          >
          > Here's my code :
          > var grpField:GroupingField = new GroupingField;
          > grpField.name = "field1"; // group on field1
          > grpField.groupingFunction = groupFunc;
          >
          > private function groupFunc(item:Object, field:GroupingField):String
          > {
          > // display field2 as the label of the group
          > return item.field2;
          > }
          >
          > Result : He actually groups on field2, ignoring totally field1.
          > the documentation says that groupingFunction is "A function that
          > determines the label for this group", and not a function who is
          > supposed to influence the grouping.
          >
          > Help me, I'm kind of lost :)

          I think that for purposes of grouping, the label of the group determines the
          grouping. You can probably display a different label with a separate label
          function.

          HTH;

          Amy