1 Reply Latest reply on Sep 24, 2009 7:51 AM by flexprad09

    Make datafield in datagrid a hyperlink to website

    Marlene Level 1

      I makes an HTTPService request which returns data to a datagrid. One of the returned fields is a website (without the "http://www" and ".com" so basically just the guts ("mywebsite"). I want to make the datafield an active link but do not know where or how to do this.

       

       

      THanks

        • 1. Re: Make datafield in datagrid a hyperlink to website
          flexprad09 Level 2

           

           

           

           

           

           

           

           

           

           

           

           

           

          You can Use A Renderer For that and can use Link Buttton as a component.

          Sample code below: I have Hard coded URL you can use data.url from your HttpService result.

           

          Application:::

           

          <?xml version="1.0"?>

          <mx:Application

          xmlns:mx="http://www.adobe.com/2006/mxml" backgroundColor="white" backgroundGradientColors="[0xFFFFFF, 0xFFFFFF]">

          <mx:Script>

          <![CDATA[

          import

           

          mx.collections.ArrayCollection;

          [

          Bindable]

          public

           

          var myAC:ArrayCollection = new ArrayCollection([

          {firstName:

          "Prad",lastName:"Shek",url:"http://www.compassites.net"},

          {firstName:

          "Alex",lastName:"Harui",url:"http://www.adobe.com"}

          ]);

          ]]>

          </mx:Script>

          <mx:DataGrid

          id="dg" width="500" height="100" dataProvider="{myAC}">

          <mx:columns>

          <mx:DataGridColumn

          dataField="firstName" headerText="First Name"/>

          <mx:DataGridColumn

          dataField="lastName" headerText="Last Name"/>

          <mx:DataGridColumn

          headerText="URL" itemRenderer="LinkREnderer"/>

          </mx:columns>

           

          </mx:DataGrid>

          </mx:Application>

           

           

           

          Renderer::::

           

           

          <?xml version="1.0" encoding="utf-8"?>

          <mx:LinkButton

           

          xmlns:mx="http://www.adobe.com/2006/mxml" label="Click On Me" click="navigateToURL(new URLRequest('http://www.compassites.net'))

          "/>

           

          If this post answers your question or helps, please mark it as such.

           

          Cheers,

           

          Prad.