1 Reply Latest reply on May 13, 2006 2:40 AM by Jesus Iglesias

    ColumnIndex on custom DataGridItemRenderer

    Jesus Iglesias
      Hi,

      Is ther a way to obtain de columnIndex withina datagriditemrenderer?

      My itemrenderer is like this

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" doubleClickEnabled="true"
      backgroundColor="{colorfondo}" creationComplete="inicia()">
      <mx:Script>
      <![CDATA[

      [Bindable]
      public var colorfondo:Number;

      ]]>
      </mx:Script>
      </mx:Canvas>


      Now I need to read the columnIndex on as for theese renderer.

      Thanks
        • 1. Re: ColumnIndex on custom DataGridItemRenderer
          Jesus Iglesias Level 1
          Hi again,

          I finally found the solution. In my renderer I doon't know the datafield name cause I don't know how many columns I have, are dynamic, and datafields are "1", "2", "3".. and so on.

          Solution. As my renderer extended from canvas and it does not implement IDropInListItemRendere, i have to make it implents and then create get/set listData methods, then all is easy:



          <?xml version="1.0" encoding="utf-8"?>
          <mx:Canvas xmlns:mx=" http://www.adobe.com/2006/mxml" xmlns="*" doubleClickEnabled="true"
          implements="mx.controls.listClasses.IDropInListItemRenderer">
          <mx:Script>
          <![CDATA[
          import mx.controls.dataGridClasses.DataGridListData;
          import mx.controls.listClasses.BaseListData;
          import mx.events.*;

          private var __listData:BaseListData;
          [Bindable("dataChange")]
          public function get listData():BaseListData{
          return __listData;
          }
          public function set listData(value:BaseListData):void{
          __listData = value;
          dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));
          }

          ]]>
          </mx:Script>
          </mx:Canvas>

          Now you can make your script access
          var data as DataGridListData =__listData as DataGridListData;

          And data is the standard data from an itemrenderer.