3 Replies Latest reply on Oct 15, 2008 8:35 AM by MacGyverMan

    ADG custom sorting and icons

    MacGyverMan Level 1
      I've got flat data coming from AMFPHP as an array collection of objects with properties such as

      type
      grade
      day_number
      subject
      ...

      Some of the data is special, marked as an "adder" (adder=1). The adder must show up at the top of the list and have a specific icon (plus sign or something). All other entries must be sorted alphabetically under the adder and have another icon (trash can).

      When the user clicks the "adder", they edit their new entry, upon completion, the entry is added to the list and the adder is maintained. A behaviour similar to powerpoint when creating bullets (a temporary entry awaits an edit, if there is one, a new entry is created).

      I've been reading until I can't stand it anymore...people talk about custom item renders, subclassing etc. I understand that, however, I have no clue what I need to do (which function(s) to overload) to achieve this behaviour.

      Also, the data is grouped via a grouping collection, so that the user can navigate to a specific day, grade and then class to add/edit. Again, I'd like to change the icons for the folders based on their function.


      In summary:
      1. What do I do to customize the sorting of data in the ADG (take an item out of the sort and put it first).
      2. What do I do to change the icons for specific leaf nodes so that some icons will be trash cans and others will be plus signs.
      3. What do I do to change the itemClick behaviour so that if the user clicks an item with a trash can, the item is deleted but not if the user clicks an item witha plus sign.
      4. What do I do to change the folder icon based on the item type and the item depth (so that each level has a different icon).

      If this is simple, I apologize. Everything seems simple for people in flex, and yet I've been working tens of hours on this stupid problem and cannot solve it. Flex could be great if I could understand the damn thing....Go PHP! :o)
        • 1. Re: ADG custom sorting and icons
          Level 7

          "MacGyverMan" <webforumsuser@macromedia.com> wrote in message
          news:gd0so7$2u5$1@forums.macromedia.com...
          > I've got flat data coming from AMFPHP as an array collection of objects
          > with
          > properties such as
          >
          > type
          > grade
          > day_number
          > subject
          > ...
          >
          > Some of the data is special, marked as an "adder" (adder=1). The adder
          > must
          > show up at the top of the list and have a specific icon (plus sign or
          > something). All other entries must be sorted alphabetically under the
          > adder and
          > have another icon (trash can).
          >
          > When the user clicks the "adder", they edit their new entry, upon
          > completion,
          > the entry is added to the list and the adder is maintained. A behaviour
          > similar
          > to powerpoint when creating bullets (a temporary entry awaits an edit, if
          > there
          > is one, a new entry is created).
          >
          > I've been reading until I can't stand it anymore...people talk about
          > custom
          > item renders, subclassing etc. I understand that, however, I have no clue
          > what
          > I need to do (which function(s) to overload) to achieve this behaviour.
          >
          > Also, the data is grouped via a grouping collection, so that the user can
          > navigate to a specific day, grade and then class to add/edit. Again, I'd
          > like
          > to change the icons for the folders based on their function.
          >
          >
          > In summary:
          > 1. What do I do to customize the sorting of data in the ADG (take an item
          > out
          > of the sort and put it first).

          I think the only kind of Hierarchical Collection you can do this with is a
          GroupingCollection. You'll need to use a compareFunction on the Grouping
          and/or GroupingField to always return -1 for that particular item.

          > 2. What do I do to change the icons for specific leaf nodes so that some
          > icons
          > will be trash cans and others will be plus signs.

          Look at iconFunction.
          http://livedocs.adobe.com/flex/3/langref/mx/controls/listClasses/AdvancedListBase.html#ico nFunction

          Despite what the docs for AdvancedDataGrid say, it _does_ support the
          iconFunction property.

          > 3. What do I do to change the itemClick behaviour so that if the user
          > clicks
          > an item with a trash can, the item is deleted but not if the user clicks
          > an
          > item witha plus sign.

          The ListEvent you get from itemClick will have a property called
          currentTarget. If you look at currentTarget.data, it will have the
          information for the entire row. Check whatever property you used in your
          iconFunction to show the trash can vs. the plus sign, and perform the
          different functionality.

          > 4. What do I do to change the folder icon based on the item type and the
          > item
          > depth (so that each level has a different icon).

          Look at the docs for groupIconFunction.
          http://livedocs.adobe.com/flex/3/html/advdatagrid_06.html

          > If this is simple, I apologize. Everything seems simple for people in
          > flex,
          > and yet I've been working tens of hours on this stupid problem and cannot
          > solve
          > it. Flex could be great if I could understand the damn thing....Go PHP!
          > :o)

          It takes everyone a long time to figure out what's going on in Flex, but
          once you do, it is amazing :-).

          I did an example with a GroupingCollection that you may or may not find
          useful, since I deliberately was _not_ using it for an ADG.
          http://flexdiary.blogspot.com/2008/09/groupingcollection-example-featuring.html

          I also have a demo here that shows using an iconFunction, though, again, not
          with an ADG
          http://flexdiary.blogspot.com/2008/08/tilelist-with-stylefunction.html

          HTH;

          Amy


          • 2. Re: ADG custom sorting and icons
            MacGyverMan Level 1
            Thanks Amy, I'll have a look at that when I get home from work.

            God I hate trying to understand flex...it seems like it was engineered to be too simple and too powerful, consequently, I can't find anything I need :o)
            • 3. ADG custom sorting and icons
              MacGyverMan Level 1
              ..oops posted in wrong thread...