4 Replies Latest reply on Aug 24, 2009 6:58 AM by pkatpadi

    How to add a Hyperlink to open popup in dynamic data grid?

    himanshuFlex

      Hi,

       

      I am a new bie in FLEX, the question which I am asking might be very easy but i am not able to find solution to it. Please can some one help me.

       

      I am creating a data grid dynamically using action script code now I want to add a Hyper link to couple of columns in a row. How can I do it in FLex?

       

      Thanks.

        • 1. Re: How to add a Hyperlink to open popup in dynamic data grid?
          *Prashant Shelke* Level 4

          Please see following code.


          Loop on dataGrid column array

          {

                    if(dataGrid.columns[cnt].dataField == "dataField") // here you can make choice for which column u want link.
                    {
                               var classFacory:ClassFactory = new ClassFactory(LinkRenderer); // here LinkRenderer is any mxml/ as file Having Link Button defined.
                              dataGrid.columns[cnt].itemRenderer = classFacory;
                   }

          }


          Hope this will work for u.


          Thanks.

          • 2. Re: How to add a Hyperlink to open popup in dynamic data grid?
            himanshuFlex Level 1

            HI Prashant,

             

            Thanks for the reply.

             

            This is what I am currently doing right now:

             

             

             

             

             

             

            for

             

            (var

            i:int=0; i<colNameList.length;i++) {

             

             

             

            var headerText:String = colNameList[i] + ""

            ;

             

            callSellGridCol = cols[i];

            callSellGridCol.headerText = headerText;

             

             

             

            if(headerText != null && headerText == "RIC"

            )

            {

             

             

            var myRenderer : ClassFactory = new

            ClassFactory(com.db.carving.synthetic.dma.view.UrlLinkRenderer);

             

             

            In My Renderer class :

             

            public

             

            class UrlLinkRenderer extends LinkButton

            {

             

            public var clickFunction:Function;

             

             

            public function UrlLinkRenderer() {

             

             

            super();

            }

             

             

            // Override the set method for the data property.

             

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

            {

             

            super.data = value;

             

             

            if (value != null)

            {

            label = value[DataGridListData(listData).dataField];

            }

             

            else

            {

            label =

            "";

            }

             

            super.invalidateDisplayList();

            }

             

            Now what i want is to add a new Event Listner to this object so that I can click it?

             

            In your suggestion you said:

             

                                 var classFacory:ClassFactory = new ClassFactory(LinkRenderer); // here LinkRenderer is any mxml/ as file Having Link Button defined.

             

            Where should be the Link button defined??

             

            Thanks.

            • 3. Re: How to add a Hyperlink to open popup in dynamic data grid?
              *Prashant Shelke* Level 4

              Hi,


              see following code,


              var myRenderer : ClassFactory = new

              ClassFactory(com.db.carving.synthetic.dma.view.UrlLinkRenderer);


              callSellGridCol.headerText = headerText;


              callSellGridCol.itemRenderer = myRendere;// Your Link button code is in actionscript!



              & in constructor


              public function UrlLinkRenderer() {

               

               

              super();

              this.addEventListener(MouseEvent.CLICK,onClickLinkButton);

              }

               

              public function onClickLinkButton(event:MouseEvent)

              {

                your code will go here...

              }

               

              Hope this will help u.

              • 4. Re: How to add a Hyperlink to open popup in dynamic data grid?
                pkatpadi Level 1

                Hi I was looking at one of your solutions and I have a problem which is closely associated to your post. I was wondering if you had any thoughts.

                 

                http://forums.adobe.com/thread/481756?tstart=0