Your itemRenderer is not a ComboBox, it is a VBox containing a ComboBox. The DataGrid sets the .data property on the VBox and you haven't written the code to pass it on down to the ComboBox.
You can either write that code, or use ComboBox as the top-level tag so you are really using a subclass of ComboBox as the renderer, which is the recommended practice. -Alex ________________________________ From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Steve Gustafson Sent: Thursday, March 01, 2007 3:45 AM To: [email protected] Subject: [flexcomponents] Struggling with itemRenderer in DataGrid Help. I posted this on FlexCoders with no response, so I thought I would try here too. I'm trying to use an itemRenderer to create a comboBox in a DataGrid that is being created with AS. I can create the comboBox, but I am struggling with being able to change the dataProvider for the rendered comboBox, and setting the selected index on the comboBox. The relevant code I am using is below. Any help is GREATLY APPRECIATED as I am rapidly approaching a deadline. Steve public function createPositionTable():void { _datagrid = positionsGrid; // positionsGrid is an already created DataGrid object _col1 = new DataGridColumn; _col2 = new DataGridColumn; _col3 = new DataGridColumn; _col4 = new DataGridColumn; _col5 = new DataGridColumn; _col1.headerText= "Position"; _col1.dataField = "Description"; _col1.editable = true; _col1.width = 100; _col2.dataField = "Type"; _col2.headerText= "Type"; _col2.editable = true; _col2.width = 50; _col3.dataField = "levelCode"; _col3.headerText = "Level Code"; _col3.width = 150; _col3.editable = false; _col3.itemRenderer = new ClassFactory(cbRender); // HERE IS WHERE I AM CREATING THE COMBO BOX _col3.editorDataField = "levelCode"; _columns = new Array(_col1,_col2,_col3); _datagrid.columns = _columns _datagrid.sortableColumns = false; _datagrid.dataProvider = objAdminTableGridDP; _datagrid.dragEnabled = false; _datagrid.dragMoveEnabled = false; _datagrid.dropEnabled = false; _datagrid.editable = true; _datagrid.rowHeight = 30; updateTablesButton.label = 'Update Positions Table'; } ------------------------------------ cbRender.mxml <?xml version="1.0" encoding="utf-8"?> <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml <http://www.adobe.com/2006/mxml> " width="50" height="25"> <mx:Script> <![CDATA[ import mx.utils.ObjectUtil; [Bindable] public var myLevels:Array = [{label:"Accounting", data:"accounting"}, {label:" Administator", data:"1"}, {label:"Programmer", data:"2"}, {label:"Vice President", data:"3"}, {label:"President", data:"4"},]; public var cboLevelID:String = ''; public function get setLevel():String { return cboLevels.selectedItem.data; } ]]> </mx:Script> <mx:ComboBox id="cboLevels" dataProvider="{myFolders}"/> </mx:VBox>
