7 Replies Latest reply on Oct 31, 2008 2:22 PM by Newsgroup_User

    ADG - Reacting when icon is clicked

    MacGyverMan
      I've got an ADG where each leaf node has one of 2 icons: a plus (if the item is known as an adder) or a trash can (otherwise).

      I've got the icon being set by iconfunction using the attached code.

      How do I set it so that the user can click the icon and trigger a given function (deleteItem in the case of the trashcan). Do I have to use a custom itemRenderer with a button instead of an icon? I'd rather not, since I can't seem to get my item renderers to make sense.
        • 1. Re: ADG - Reacting when icon is clicked
          Level 7

          "MacGyverMan" <webforumsuser@macromedia.com> wrote in message
          news:ge206t$12p$1@forums.macromedia.com...
          > I've got an ADG where each leaf node has one of 2 icons: a plus (if the
          > item is
          > known as an adder) or a trash can (otherwise).
          >
          > I've got the icon being set by iconfunction using the attached code.
          >
          > How do I set it so that the user can click the icon and trigger a given
          > function (deleteItem in the case of the trashcan). Do I have to use a
          > custom
          > itemRenderer with a button instead of an icon? I'd rather not, since I
          > can't
          > seem to get my item renderers to make sense.
          >
          >
          > public function setIcon(item:Object):Class
          > {
          > if(item.hasOwnProperty('adder') && item['adder']==1)
          > return add;
          > else if(!item.hasOwnProperty('children'))//If there are children, the
          > node
          > is a branch, so we don't want to enable deleting
          > return trash;
          > return null;
          > }

          In your itemClick, look at the same information you look at in the
          iconFunction property...


          • 2. Re: ADG - Reacting when icon is clicked
            MacGyverMan Level 1
            Thanks for the answer.

            I've thought of that, however, I want to react differently when clicking the icon than when clicking the row.

            When clicking the row, the item editor opens up. If the trash can is clicked, the user is prompted to delete the item
            • 3. Re: ADG - Reacting when icon is clicked
              Level 7

              "MacGyverMan" <webforumsuser@macromedia.com> wrote in message
              news:geas6f$l91$1@forums.macromedia.com...
              > Thanks for the answer.
              >
              > I've thought of that, however, I want to react differently when clicking
              > the
              > icon than when clicking the row.
              >
              > When clicking the row, the item editor opens up. If the trash can is
              > clicked,
              > the user is prompted to delete the item

              You still can determine if the situation is appropriate by looking at
              exactly the same information.


              • 4. Re: ADG - Reacting when icon is clicked
                MacGyverMan Level 1
                How?

                If the person clicks on the row itself, the editor opens up. If they click on the trash, the item should be deleted. The info stored in the item will not determine if the user want's to delete or edit the item.
                • 5. Re: ADG - Reacting when icon is clicked
                  Level 7

                  "MacGyverMan" <webforumsuser@macromedia.com> wrote in message
                  news:gedo26$qoe$1@forums.macromedia.com...
                  > How?
                  >
                  > If the person clicks on the row itself, the editor opens up. If they click
                  > on
                  > the trash, the item should be deleted. The info stored in the item will
                  > not
                  > determine if the user want's to delete or edit the item.

                  Ah, I thought that the problem was that you didn't know which ones _had_
                  trash can icons. Edit your itemRenderer to generate a different event when
                  the trash can is clicked.


                  • 6. Re: ADG - Reacting when icon is clicked
                    MacGyverMan Level 1
                    It's all good.

                    That's the problem I'm facing. I have no clue how to generate a different event when the can is clicked.

                    Right now I'm not using a custom item renderer. I just used iconFunction to make the icons.

                    I've tried the custom renderer, however, they don't indent to follow the tree once it's expanded. They all align to the left..
                    • 7. Re: ADG - Reacting when icon is clicked
                      Level 7

                      "MacGyverMan" <webforumsuser@macromedia.com> wrote in message
                      news:gefndn$h6n$1@forums.macromedia.com...
                      > It's all good.
                      >
                      > That's the problem I'm facing. I have no clue how to generate a different
                      > event when the can is clicked.
                      >
                      > Right now I'm not using a custom item renderer. I just used iconFunction
                      > to
                      > make the icons.
                      >
                      > I've tried the custom renderer, however, they don't indent to follow the
                      > tree
                      > once it's expanded. They all align to the left..

                      You might be able to use a click event and look at the event.target and see
                      what the className is of the target. Then you'll have to walk up from there
                      to get the renderer itself and look at the data.

                      Or you could just subclass the AdvancedDataGridGroupItemRenderer and add an
                      event listener to the icon...