Skip navigation
Currently Being Moderated

ComboBox in a Spark DataGrid

Jul 5, 2011 7:46 AM



Is there any difference between setting the data provider of a combo box in the MXML, and setting it from an actionscript code?


In the example below I create a table. The first column has combo editor with data provider set in the mxml. For the second I listen for a grid item editor session start event and then set the data provider. I expect that both columns should behave the same, but if I click on item from the second column, then it's not selected in the list and moreover is cleared when I click another cell. Could you please help? What could be the problem?


<?xml version="1.0" encoding="utf-8"?>
<s:WindowedApplication xmlns:fx="" 
               import mx.controls.ComboBox;
               import spark.components.gridClasses.ComboBoxGridItemEditor;

               protected function creationCompleteHandler(event:FlexEvent):void
                    grid.dataProvider = new ArrayList([
                    grid.addEventListener(GridItemEditorEvent.GRID_ITEM_EDITOR_SESSION_START, prepareCellEditor);
               protected function prepareCellEditor(event:GridItemEditorEvent):void
                    if (event.column.dataField == 'column2') {                         
                         var comboEditor : ComboBoxGridItemEditor = event.currentTarget.itemEditorInstance as ComboBoxGridItemEditor;
                         comboEditor.dataProvider = new ArrayList(['red','green','blue']);               

     <s:DataGrid id="grid" editable="true" width="100%" height="100%">          
                    <s:GridColumn dataField="column1" headerText="Column 1">
                    <s:GridColumn dataField="column2" headerText="Column 2" itemEditor="spark.components.gridClasses.ComboBoxGridItemEditor"/>
                    <s:GridColumn dataField="column3" headerText="Column 3"/>


Thanks in Advance!




  • Currently Being Moderated
    Apr 3, 2013 6:40 AM   in reply to dinko_ivanov

    to set the dataProvider of the ComboBoxGridItemEditor dynamically in ActionScript

    I use this:



    var dataList:ArrayList = new ArrayList(["one", "two", "three"]);

    var cF:ClassFactory = new ClassFactory(ComboBoxGridItemEditor); = {dataProvider: dataList};


    yourEditableColumn.itemEditor = cF;


    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points