Re: [flexcomponents] Struggling with itemRenderer in DataGrid
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. --
Re: [flexcomponents] Struggling with itemRenderer in DataGrid
I would try this. var cf:ClassFactory = new ClassFactory(yourItemRenderer); cf.properties = {dataProvider:myCBData}; col3.itemRenderer = cf. On 3/2/07, Steve Gustafson [EMAIL PROTECTED] wrote: 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. -- -- justin w. opitz 617.771.6639 jwopitz(at)gmail.com
Re: [flexcomponents] Struggling with itemRenderer in DataGrid
maybe trying to set the properties while it is referenced by the col's itemRenderer is throwing some errors. On 3/2/07, jwopitz [EMAIL PROTECTED] wrote: I would try this. var cf:ClassFactory = new ClassFactory(yourItemRenderer); cf.properties = {dataProvider:myCBData}; col3.itemRenderer = cf. On 3/2/07, Steve Gustafson [EMAIL PROTECTED] wrote: 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. -- -- justin w. opitz 617.771.6639 jwopitz(at)gmail.com -- justin w. opitz 617.771.6639 jwopitz(at)gmail.com
RE: [flexcomponents] Struggling with itemRenderer in DataGrid
You'll have to override the data setter. override public function set data(value:Object):void { } The value object contains the data for an entire row in the DataGrid. If you can then calculate the selectedIndex based on the data in the row, you are set to go. From: flexcomponents@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Gustafson Sent: Friday, March 02, 2007 8:36 AM To: flexcomponents@yahoogroups.com Subject: Re: [flexcomponents] Struggling with itemRenderer in DataGrid That is exactly the solution I hit upon this morning. Now I am trying to work through how to have a different selectedIndex in the ItemRenderer for each row in the datagrid. Any thoughts? Thanks, Steve On 3/2/07, jwopitz [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I would try this. var cf:ClassFactory = new ClassFactory(yourItemRenderer); cf.properties = {dataProvider:myCBData}; col3.itemRenderer = cf.
RE: [flexcomponents] Struggling with itemRenderer in DataGrid
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: flexcomponents@yahoogroups.com [mailto:[EMAIL PROTECTED] On Behalf Of Steve Gustafson Sent: Thursday, March 01, 2007 3:45 AM To: flexcomponents@yahoogroups.com 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
Re: [flexcomponents] Struggling with itemRenderer in DataGrid
OK, now I've gotten rid of the VBox, but still do not see how I can set a different dataProvider to the comboBox, or dynamically set the selectedIndex. Again any help is greatly appreciated. Steve On 3/1/07, Alex Harui [EMAIL PROTECTED] wrote: 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:* flexcomponents@yahoogroups.com [mailto:flexcompone [EMAIL PROTECTED] *On Behalf Of *Steve Gustafson *Sent:* Thursday, March 01, 2007 3:45 AM *To:* flexcomponents@yahoogroups.com *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; 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
Re: [flexcomponents] Struggling with itemRenderer in DataGrid
First off, reinstate the VBox. The override the setter data (value:Object). There you can either set the cb's dataProvider like cb.dp = data.someObject or if you are doing it in MXML, you can bind the dataprovider of the CB to some expected property of the data property of the VBox. Doing it via script is a bit tricky, because if your data value doesn't contain the targeted property it will throw a runtime error. On 3/1/07, Steve Gustafson [EMAIL PROTECTED] wrote: OK, now I've gotten rid of the VBox, but still do not see how I can set a different dataProvider to the comboBox, or dynamically set the selectedIndex. Again any help is greatly appreciated. Steve On 3/1/07, Alex Harui [EMAIL PROTECTED] wrote: 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:* flexcomponents@yahoogroups.com [mailto:[EMAIL PROTECTED] *On Behalf Of *Steve Gustafson *Sent:* Thursday, March 01, 2007 3:45 AM *To:* flexcomponents@yahoogroups.com *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; 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 -- justin w. opitz 617.771.6639 jwopitz(at)gmail.com
RE: [flexcomponents] Struggling with itemRenderer in DataGrid
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] mailto:[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. From: flexcomponents@yahoogroups.com mailto:flexcomponents@yahoogroups.com [mailto:flexcomponents@yahoogroups.com mailto:flexcomponents@yahoogroups.com ] On Behalf Of jwopitz Sent: Thursday, March 01, 2007 12:01 PM To: flexcomponents@yahoogroups.com mailto:flexcomponents@yahoogroups.com Subject: Re: [flexcomponents] Struggling with itemRenderer in DataGrid First off, reinstate the VBox. The override the setter data (value:Object). There you can either set the cb's dataProvider like cb.dp = data.someObject or if you are doing it in MXML, you can bind the dataprovider of the CB to some expected property of the data property of the VBox. Doing it via script is a bit tricky, because if your data value doesn't contain the targeted property it will throw a runtime error. On 3/1/07, Steve Gustafson [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: OK, now I've gotten rid of the VBox, but still do not see how I can set a different dataProvider to the comboBox, or dynamically set the selectedIndex. Again any help is greatly appreciated. Steve On 3/1/07, Alex Harui [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Your itemRenderer is not a ComboBox, it is a VBox containing
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. -- *From:* flexcomponents@yahoogroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *jwopitz *Sent:* Thursday, March 01, 2007 12:01 PM *To:* flexcomponents@yahoogroups.com *Subject:* Re: [flexcomponents] Struggling with itemRenderer in DataGrid First off, reinstate the VBox. The override the setter data (value:Object). There you can either set the cb's dataProvider like cb.dp= data.someObject or if you are doing it in MXML, you can bind the dataprovider of the CB to some expected property of the data property of the VBox. Doing it via script is a bit tricky, because if your data value doesn't contain the targeted property it will throw a runtime error. On 3/1/07, *Steve Gustafson* [EMAIL PROTECTED] wrote: OK, now I've gotten rid of the VBox, but still do not see how I can set a different dataProvider to the comboBox, or dynamically set the selectedIndex. Again any help is greatly appreciated. Steve On 3/1/07, *Alex Harui* [EMAIL PROTECTED] wrote: 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:* flexcomponents@yahoogroups.com [mailto: [EMAIL PROTECTED] *On Behalf Of *Steve Gustafson *Sent:* Thursday, March 01, 2007 3:45 AM *To:* flexcomponents@yahoogroups.com *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