1 Reply Latest reply on Dec 8, 2009 8:52 AM by Gregory Lafrance

    Accessing DataGrid currentTarget from a dataGridColumn button

    rcanulla Level 1

      I am trying to access the row item clicked from within a datagrib button. Any thoughts? It seems to only accept event or mouseevent...


                     public function onDeleteItem(e:Event):void{
      <mx:DataGridColumn headerText="Remove" width="60">
                                               <mx:Box horizontalAlign="center" verticalAlign="middle">     
                                                    <mx:Button skin="@Embed('assets/remove_icon.png')" 
                                                         buttonMode="true" scaleX=".6" scaleY=".6" click="outerDocument.onDeleteItem(event)" />           
        • 1. Re: Accessing DataGrid currentTarget from a dataGridColumn button
          Gregory Lafrance Level 6

          You need to access the dataProvider using the DataGrid selectedItem property.



          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"> 
                import mx.collections.ArrayCollection;
                [Bindable] private var ac:ArrayCollection = new ArrayCollection([
                  {test: "one"}, {test: "two"}, {test: "three"}, {test: "four"}, {test: "five"}
                public function clickFunc():void{
                  txt.text = dg.selectedItem.test;
            <mx:DataGrid id="dg" dataProvider="{ac}">
                <mx:DataGridColumn dataField="test">
                      <mx:Button label="Click Me" click="outerDocument.clickFunc();"/>
            <mx:Text id="txt"/>

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

          Greg Lafrance

          Flex Development and Support Services