3 Replies Latest reply on Aug 4, 2010 10:38 PM by Benoitcn

    Custom DataGridColumn pass data to ItemRenderer

    Benoitcn Level 1

      I use as3 syntax to create some advancedDataGridColumns and indicate to use cusItemRenderer

      by "col.itemRenderer = itemRenderer;" .

      I override the function set ItemRenderer  in the customed AdvancedDataGridColumn class.

      But the itemrenderer can't get the data. 

       

      Is there anyway to get the properties "datafield" and "headerText" of the DataGridColumn in the itemRenderer ?

       

      This is my code:

       

       

           // I create a ItemRenderer to pass to all the DataGirdColumns

           var itemRenderer:cusItemRenderer = new cusItemRenderer();

          // I create some columns         

           col = new AdvancedDataGridColumn(flatColumns[i].Label);
           col.dataField = "@" + flatColumns[i].Field;

           col.itemRenderer = itemRenderer;

       

       

      public class cusAdvancedDataGridColumn extends AdvancedDataGridColumn
      {
             override public function set itemRenderer(value:IFactory):void{


                   var itemRenderer:cusItemRenderer = value as cusItemRenderer;
        
                   itemRenderer.parentField = this.dataField;
                   itemRenderer.parentLabel = this.headerText;

        
                   super.itemRenderer(itemRenderer);

             }


      }

       

       

       

       

      public class cusItemRenderer extends AdvancedDataGridItemRenderer implements IFactory
      {
       
             // They're alway null ~!
             public var parentField  :String = null;
            
      public var parentLabel :String = null;

       

           public function newInstance():*{
              return new cusItemRenderer();
           }

      }