Suraj,
Did you try like this..
                      var col1 : AdvancedDataGridColumn = new
AdvancedDataGridColumn();
                        col1.headerText = "Board";
                        col1.dataField = "board";
                        col1.width = advGrid.width * 0.2;
                        col1.itemRenderer =  new ClassFactory(*ItemRendMxml*
); ;

new ClassFactory(ItemRendMxml);, Here we should pass the fully qualified
class name. means include its package name.
You can even set properties for the custom item renderer. here is sample
one.

var itemRenderer:ClassFactory = new ClassFactory(mx.controls.ComboBox);
itemRenderer.properties = {dataProvider: cbDataProvider};
col1.itemRenderer = itemRenderer;


Thanks,
Nagarjuna



On Mon, Jun 11, 2012 at 7:30 PM, Suraj Gagain <[email protected]>wrote:

> Hi,
>
> I need your help for this.
> I have an advanced data grid to which i am adding the columns
> dynamically.I am able to do it but the problem arises when i attempt
> to use an item-renderer.
> I am adding this  item-renderer in the label function for the column.
>
> Code---------
>                          var existingCol:Array =
> advGrid.groupedColumns;
>                         var col1 : AdvancedDataGridColumn = new
> AdvancedDataGridColumn();
>                         col1.headerText = "Board";
>                         col1.dataField = "board";
>                         col1.width = advGrid.width * 0.2;
>                         col1.labelFunction = applyItemRenderer;
>                         existingCol.push(col1);
>                         var col2 : AdvancedDataGridColumn = new
> AdvancedDataGridColumn();
>                         col2.headerText = "School Name";
>                         col2.dataField = "schoolName";
>                         col2.width = advGrid.width * 0.3;
>                         col2.labelFunction = applyItemRenderer;
>                         existingCol.push(col2);
>                         advGrid.groupedColumns = existingCol;
>
>                       private function
> applyItemRenderer(item:Object,column:AdvancedDataGridColumn):void{
>                            staticVar = item[column.dataField];
>                            column.itemRenderer = new
> ClassFactory(ItemRendMxml);
>                        }
>
>  item-renderer -- ItemRendMxml--
>
> <?xml version="1.0" encoding="utf-8"?>
> <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml";
> initialize="{setText();}">
>
> <mx:Script>
>        <![CDATA[
>                import mx.core.Application;
>                import mx.controls.Alert;
>
>                public function setText():void{
>                 txtLbl.text = Application.application.staticVar;
>                }
>        ]]>
> </mx:Script>
>        <mx:Label id="txtLbl"/>
> </mx:HBox>
>
> Here the problem is that the school name is getting displayed under
> board and board is getting displayed under school name.
> I tried various versions but nothing seems to work for me.
>
> Please help me to get out of this.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Flex India Community" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/flex_india?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups "Flex 
India Community" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en.

Reply via email to