-
applying a different array for a combobox
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:
import mx.controls.ComboBox;
import mx.controls.DataGrid;
class ComboBoxCell extends MovieClip {
private var _ccbMenu:ComboBox;
private var listOwnerataGrid;
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|