Use an Item Renderer:

package renderers
{
     import mx.controls.*;
     import mx.controls.dataGridClasses.DataGridListData;

     public class myColumnRenderer extends LinkButton
     {
         private var fieldValue:String;

         public function myColumnRenderer()
         {
             super();
         }

         override public function set data(value:Object):void
         {
             if(value != null)
             {
                 super.data = value;
                 fieldValue =
value[DataGridListData(listData).dataField];
                 label = fieldValue;
                 enabled = true;
                 useHandCursor = true;
                 setStyle("color", "#0000FF");
                 setStyle("textRollOverColor:", "#0000CC");
             }
         }
     }
}

To use it:

<mx:DataGridColumn headerText="Ability" dataField="ability"
itemRenderer="renderers.myColumnRenderer">


--- In [email protected], "timgerr" <[EMAIL PROTECTED]> wrote:
>
> Hello all,
> I was wondering how to do somtgin that I think is complicated.  I want
> to have a button in a DataGridColumn, I would like to have the button
> label be set to the data returned in that fataField.  Here is what I
mean:
>
> <mx:DataGrid id="MEDG"  width="100%" height="100%">
>   <mx:columns>
>     <mx:DataGridColumn headerText="Name" dataField="name"/>
>     <mx:DataGridColumn headerText="Manufacturer"
>         dataField="manufacturer"/>
>     <mx:DataGridColumn headerText="Version" dataField="version"/>
>     <mx:DataGridColumn headerText="Ability" dataField="ability">
>       <mx:itemRenderer>
>  <mx:Component>
>    <mx:HBox horizontalAlign="center">
>             <mx:Button label="{outerDocument.MEDG.ability}"/>
>           </mx:HBox>
>  </mx:Component>
>       </mx:itemRenderer>
>     </mx:DataGridColumn>
>   </mx:columns>
> </mx:DataGrid>
>
> How can I set the button:
> <mx:Button label="{outerDocument.MEDG.ability}"/>
>
> to equal the data contained in:
> <mx:DataGridColumn headerText="Ability" dataField="ability">
>
> Thanks for the help,
> timgerr
>

Reply via email to