3 Replies Latest reply on Aug 27, 2012 6:45 AM by Jerry62712

    Bubble verification

    Jerry62712 Level 1

      I just changed a grid from having a button to having a link.  The link is formed in an itemrenderer.  IIRC, an event established there will bubble up to the container (a grid) and then the class if it isn't handled there.

       

      The renderer has this:

       

                  lb2.addEventListener(MouseEvent.CLICK,getAA);

                  addChild(lb2);

              }

       

              public function getAA(event:Event):void

              {

                  (new UserAARetrieveEvent(_aaRetrieve)).dispatch();

                  //selectTopGridHandler

          //        parentDocument.

             }      

       

      The containing UserAA_Grid.mxml includes this:

       

      private function dgCreationCompleteHandler(e:FlexEvent):void

      {

        // if checkbox renderer - this worked, but is being changed to a link above

        dg.addEventListener(CheckBoxRendererCust.CLICK, selectTopGridHandler);

        dg2.addEventListener(CheckBoxRendererCust.CLICK, selectBotGridHandler);

      }

       

      // Called when top grid row box checked

      public function selectTopGridHandler(data:Object):void

      {

        resultOfSearch.enabled = false;

        dg2.dataProvider = "";

        // if we use a checkbox, this will point to it being selected

        try

      ...

       

      Would adding a "dg.addEventListener(UserAARetrieveEvent..." be the way to go?

        • 1. Re: Bubble verification
          Jerry62712 Level 1

          Just an update.  In the last 4 hours I still am not getting it.

           

          I don't get an error in the renderer:

           

          override public function set data(value:Object):void

          {

            removeAllChildren();

           

            if (value == null ||

              value == "")

            {

              return;

            }

           

            super.data = value;

           

            var lb2:LinkButton = new LinkButton();

           

            if (value.rsrceID == null ||

              value.rsrceID == 0)

            {

              lb2.setStyle("color","red");

              lb2.setStyle("fontStyle","italic");

              lb2.setStyle("fontSize","10");

              lb2.label = value.individualName + ": *no act. record*";

            }

            else

            {

              lb2.setStyle("color","blue");

              lb2.label = value.individualName

                + ": " + value.rsrceID + " " + df.format(value.rspTS);

            }

           

            lb2.addEventListener(MouseEvent.CLICK, retrieveList);

            addChild(lb2);

          }

           

          public function retrieveList(event:Event):void

          {

            dispatchEvent(new Event(UserAA_NmLk_Renderer.CLICK, true, true));

          }

           

          In the component that contains the advancedatagrid where this is the first column, I do get an error:

          private function dgCreationCompleteHandler(e:FlexEvent):void

          {

          **  dg.addEventListener(UserAA_NmLk_Renderer.CLICK, selectTopGridHandler);

            // if checkbox renderer

            dg.addEventListener(CheckBoxRendererCust.CLICK, selectTopGridHandler);

            dg2.addEventListener(CheckBoxRendererCust.CLICK, selectBotGridHandler);

          }

           

          // Called when top grid row box checked

          public function selectTopGridHandler(data:Object):void

          {...}

          ** error is:

          Multiple markers at this line:

          -1120: Access of undefined property UserAA_NmLk_Renderer.

          -1 changed line

           

          What I want to happen is when the user clicks one of the links in the first column of an advancedatagrid that that click bubbles up from the itemrenderer up to the advancedatagrid up to the component where it will be processed.

           

          Using this string in google ("flex dispatch event from renderer") I haven't found a detailed explaination yet.

          • 2. Re: Bubble verification
            Jerry62712 Level 1

            Prior to this attempt to use a linkbutton (per the user's request), I was able to bubble up an event using a checkbox and a button.  I'm not sure why it won't bubble now.

            • 3. Re: Bubble verification
              Jerry62712 Level 1

              It now appears to be working.  The only major change I made was to make the literals associated with the "CLICK" constant not have underscores.  I can't imagine why that would make a difference, however.  So I could be back in ten minutes if it suddenly, again, decides that it isn't going to work.