Hi Experts, 

I'm trying to create a Flex 4.5.1 app using an AdvancedDataGrid with a column 
itemRenderer. See the code snippets below for the application and item renderer.

The problem I see is when I debug and place a break point inside 
myItemRenderer.mxml located in either of the two places shown below, the values 
for variables "value" and "data" are null.

I'm not trying to do anything unusual here (guessing it should be textbook 
implementation).

The only info I can find on ADG using item renderers, does not include where 
the columns are defined in mxml:
http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7bf2.html
 
So I suspect the column item renderers for ADG behave similar to regular mx or 
spark DataGrid. But don't I have to use an mx:AdvancedDataGridItemRenderer when 
I build the item renderer component?

How do I connect the item renderer to the ADG column so I can format the column 
data using my function: formatMyData()?

Any help to straighten me out would be much appreciated. Thanks in advance for 
any comments.


----------- CODE SNIPPETS--------------

********** Application *********

<mx:AdvancedDataGrid id="myGrid" ... >
    <mx:columns>
        <mx:AdvancedDataGridColumn id="c0" headerText="" dataField="label"/>
        <mx:AdvancedDataGridColumn id="c1" dataField="Name" 
itemRenderer="com.mycompany.myItemRenderer"/>
    </mx:columns>       
    ... data provider and other stuff not shown here...
</mx:AdvancedDataGrid>


*********  myItemRenderer.mxml *********

<mx:AdvancedDataGridItemRenderer 
        xmlns:fx="http://ns.adobe.com/mxml/2009";
        xmlns:s="library://ns.adobe.com/flex/spark" 
        xmlns:mx="library://ns.adobe.com/flex/mx">

    <fx:Script>
    <![CDATA[
                                        
        import mx.controls.AdvancedDataGrid;
                        
        override public function set data(value:Object):void {
            super.data=value;     // BREAKPOINT 1, where I see value=null 
        }
                        
        override public function validateProperties():void {
            super.validateProperties();
            text=formatFn(data);  // BREAKPOINT 2, where I see data=null
        }
                        
        private function formatMyData(data:Object):String {
            var returnedData:String;
            ... do various formatting here ...
            return returnedData;
        }

    ]]>
    </fx:Script>
</mx:AdvancedDataGridItemRenderer>

Reply via email to