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

    DataField on custom DataGrid Itemrenderer

    Jesus Iglesias
      Hi again,

      I have one datagrid with one custom column. I define de itemrenderer and its ok.
      Now I need to know the Datafield for that column within the itemrenderer, but I don´t know how to, nothing seems to work.

      Please help me, How can I now the properties of a column whitin a custom itemrenderer?

      This is how I create the column on runtime

      var col:DataGridColumn = new DataGridColumn("Monday");
      col.itemRenderer= new ClassFactory(celdaEstadoHabitacion);

      Then I need DataField and colName.

      I tried something like

      and on the itemrenderer make a bindable "myfield" variable, bur it returns ther is no property whith "myfield" name.

        • 1. Re: DataField on custom DataGrid Itemrenderer
          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"
          import mx.controls.dataGridClasses.DataGridListData;
          import mx.controls.listClasses.BaseListData;
          import mx.events.*;

          private var __listData:BaseListData;
          public function get listData():BaseListData{
          return __listData;
          public function set listData(value:BaseListData):void{
          __listData = value;
          dispatchEvent(new FlexEvent(FlexEvent.DATA_CHANGE));


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

          And data is the standard data from an itemrenderer.