# Applying a different array for a combobox

**URL:** <https://forum.kirupa.com/t/applying-a-different-array-for-a-combobox/313166>\
**Category:** Uncategorized\
**Created:** [August 23, 2010, 12:49am UTC](https://forum.kirupa.com/t/applying-a-different-array-for-a-combobox/313166 "2010-08-23T00:49:57Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![neatgadgets](https://avatars.discourse-cdn.com/v4/letter/n/ed655f/32.png) [@neatgadgets](https://forum.kirupa.com/u/neatgadgets)\
**Post date:** [August 23, 2010, 12:49am UTC](https://forum.kirupa.com/t/applying-a-different-array-for-a-combobox/313166/1 "2010-08-23T00:49:57Z")

</div>

I am having trouble applying a different array for a combobox

I have created a datagrid, and then I am trying to use cellrenderer to put a combobox in a column.

Normally I set up the datagrid, then use the following code to create the column that the combobox is going in:

var column = new DataGridColumn(“species\_id”);  
column.headerText = “species\_id”;  
column.width = 70;  
column.cellRenderer = “ComboBoxCell”;  
dgIndividualBirdData.addColumn(column);

A sample array I am wanting to add is [{label: “Test”, data: 1}];

The class is as follows:

```auto
 
import mx.controls.ComboBox;
import mx.controls.DataGrid;
 
class ComboBoxCell extends MovieClip {
 
private var _ccbMenu:ComboBox;
private var listOwner[IMG]http://www.actionscripts.org/forums/images/icons/icon10.gif[/IMG]ataGrid;
private var owner:MovieClip;
private var createClassObject:Function;
private var getCellIndex:Function;
private var getDataLabel:Function;
 
function ComboBoxCell() {
init();
}
 
private function init():Void {
createClassObject(ComboBox, "_ccbMenu", 1);
_ccbMenu.dataProvider = [];
_ccbMenu.addEventListener("change", this);
}
 
 
private function change(oEvent:Object):Void {
listOwner.editField(getCellIndex().itemIndex, getDataLabel(), _ccbMenu.value);
}
 
public function getPreferredWidth():Number {
return 100;
}
 
public function getPreferredHeight():Number {
return 25;
}
 
public function setSize(nWidth:Number, nHeight:Number):Void {
_ccbMenu.setSize(nWidth, _ccbMenu.height);
}
 
public function setValue(sLabel:String, oItem:Object, sState:String):Void {
_ccbMenu.visible = (oItem != undefined);
for(var i:Number = 0; i < _ccbMenu.length; i++) {
if(_ccbMenu.getItemAt(i).data == oItem[getDataLabel()]) {
_ccbMenu.selectedIndex = i;
break;
}
}
}
 
}

```

Just not exactly how to do this
