3 Replies Latest reply on Jul 12, 2006 5:29 PM by emiltso

    URL link in DataGrid column

    gshumw
      Hello,

      I am a newbie in Flex area, so I wonder what would be the most efficient way to implement a grid control with column with URL hyperlink, included the link behavior of hand cursor, text selection and its activation in new window?

      Regards,
      Gennady
        • 1. Re: URL link in DataGrid column
          jtan Level 1
          Gennady,

          You can do this by creating a custom itemRenderer for the DataGrid. The itemRenderer can extend the Text component and use the htmlText property of Text to assign a link to the text. Here is a simple example using an "inline itemRenderer".

          <?xml version="1.0" encoding="iso-8859-1"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" >
          <mx:Script>
          <![CDATA[
          [Bindable]
          public var myData:Array = [
          {url:" http://www.google.com", label: "Google"},
          {url:" http://www.yahoo.com", label: "Yahoo!"},
          {url:" http://www.adobe.com", label: "Adobe"}
          ];
          ]]>

          </mx:Script>

          <mx:DataGrid dataProvider="{myData}">
          <mx:columns>
          <mx:DataGridColumn dataField="label" headerText="websites">
          <mx:itemRenderer>
          <mx:Component>
          <mx:Text htmlText="&lt;a href='{data.url}'&gt;{data.label}&lt;/a&gt;" />
          </mx:Component>
          </mx:itemRenderer>
          </mx:DataGridColumn>
          </mx:columns>
          </mx:DataGrid>
          </mx:Application>
          • 2. Re: URL link in DataGrid column
            gshumw Level 1
            Thanks a lot!
            • 3. Re: URL link in DataGrid column
              emiltso
              Hello, I am also new to Flex and am using Flex to prototype a web app. I am using datagrid to bring data from an array. The datagrid I have has multiple columns. What should I do to let user click on anywhere on the row to go to a different state and click on another row to go to another state? Does your example apply when clicking on values in other columns in the same row?

              Thanks so much!
              Emil