Ok. This is alot closer to where I am trying to get!
When I try: _col3.itemRenderer.properties = {dataProvider:myCBData}; FlexBuilder throws the following error: Access of possibly undefined property properties through a reference with static type mx.core:IFactory So now it looks like I'll either have to figure out how to access the iFactory, or learn to write my own IFactory as suggested. It seems like this should be simpler! Steve On 3/1/07, Alex Harui <[EMAIL PROTECTED]> wrote:
You can write you own IFactory, or you can do this: _col3.itemRenderer = new ClassFactory(comboR); _col3.itemRenderer.properties = { dataProvider : arrayToUseAsDataProvider}; Then your ComboBox dataproviders will be given assigned that array. ------------------------------ *From:* flexcomponents@yahoogroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *Steve Gustafson *Sent:* Thursday, March 01, 2007 3:09 PM *To:* flexcomponents@yahoogroups.com *Subject:* Re: [flexcomponents] Struggling with itemRenderer in DataGrid Perhaps I am not being clear. I know I can set the dataProvider within the component. What I need to know is how I can either change the dataProvider when the itemRenderer is called. I want to use this itemRenderer in multiple grids. Each grid is to use the itemRenderer with either a different dataProvider, or update the dataProvider with different data. So I'm trying to something like: public function createPositionTable():void { _col1 = new DataGridColumn; _col2 = new DataGridColumn; _col3 = 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; // HERE I SET THE itemRenderer - but want to use a different dataProvider // OR AT LEAST UPDATE THE ORIGINAL DATAPROVIDER WITH NEW DATA _col3.itemRenderer = new ClassFactory(comboR); _col3.editorDataField = "levelCode"; _columns = new Array(_col1,_col2,_col3); _datagrid = positionsGrid; _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'; } public function createDepartmentTable():void { _col1 = new DataGridColumn; _col2 = new DataGridColumn; _col3 = 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; // HERE I SET THE itemRenderer - but want to use different dataProvider // OR AT LEAST UPDATE THE ORIGINAL DATAPROVIDER WITH NEW DATA _col3.itemRenderer = new ClassFactory(comboR); _col3.editorDataField = "levelCode"; _columns = new Array(_col1,_col2,_col3); _columns = new Array(_col1,_col2,_col3); _datagrid = positionsGrid; _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'; } On 3/1/07, *Alex Harui* <[EMAIL PROTECTED]> wrote: <mx:ComboBox dataProvider="{myLevels}" … This should set you up to use the myLevels in every ComboBox. The comboBox has built-in logic to set the selectedItem based on what it sees in the data property. In your case you might want to override the data setter and choose selectedIndex then. FWIW, using VBox to wrap will be slower than ComboBox straight up. ------------------------------