The default behavior of a ComboBox in a DataGrid is to match the field 
specified by the column to an item in the dataProvider.

If the dataProvider for the DataGrid contains:

{ firstName: “Alex”, lastName: “Harui”}

And the ComboBox dataProvider contains:

[ “Smith”, “Harui”, “Jones”]

And the column’s dataFIeld is “lastName”, it should select the second item for 
you.  Note that if the field values are not simple types, they may not match.

It might help to post an example data item for the DataGrid as well as the 
ComboBox.


On 6/7/10 8:51 AM, "Goutham" <[email protected]> wrote:






Hi

I am accessing the combobox with the id through

object.data = event.currentTarget.itemEditorInstance.foo.SelectedItem

it works fine, but the problem I have is, when I click on the combobox in the 
gird, it defaults to the first item in the dataprovider for the combobox

<combobox id="foo" dataprovider={dprovider} text="{data.DataField} 
labelField="datafield" />

the dprovider has the value cb1,cb2,cb3

when I click on the cell in the datagrid, the combobox is populated with cb1 
irrespective of the value selected.

I have also tried

<combobox id="foo" dataprovider={dprovider} selectedItem = data.DataField} 
labelField="datafield" />

this shows a blank combobox when clicked on the cell.

in both the cases it does give a warning
"unable to bind to property 'datafield' on class object

any suggestion

Thank you

--- In [email protected] <mailto:flexcoders%40yahoogroups.com> , 
"Goutham" <goldensu...@...> wrote:
>
> Hi Alex,
>
> thank you, I tried it using an id for the combobox, gives me an error
> "Access of possibly undefined property foo through a reference with static 
> type mx.containers:Grid"
>
> and there is also another problem, when I click on the column in the 
> datagrid, the itemeditor changes to a combobox with the default value to be 
> the first one in the dataprovider instead of the selected one
>
> this didn't happen in the first case (first case I mean with out using the 
> grid and gridrow) but here, I get a warning "uable to bind to property 
> 'datafield' on class 'object' (class is not an IEventDispatcher)
>
> any suggestions
>
> thank you
>
> --- In [email protected] <mailto:flexcoders%40yahoogroups.com> , 
> Alex Harui <aharui@> wrote:
> >
> > One way is to set an id="foo" on the ComboBox, then use
> >
> > object.data = 
> > ComboBox(Grid(event.currentTarget.itemEditorInstance).foo).text;
> >
> > On 6/2/10 1:00 PM, "Goutham" <goldensuits@> wrote:
> >
> >
> >
> >
> >
> >
> > Hi,
> >
> > I have a combobox in item editor in a datagrid. the combobox is populated 
> > with a dataprovider. All this works fine until I place this combobox inside 
> > a gird
> >
> > working code
> > ------------
> >
> > mxml code
> > ---------
> >
> > <datagridcolumn>
> >  <itemeditor>
> >  <component>
> >  <combobox dataprovider="{outerDocument.data}" ... />
> >  </component>
> >  </itemeditor>
> > </datagridcolumn>
> >
> > actionscript code
> > -----------------
> > object.data = ComboBox(event.currentTarget.itemEditorInstance).text;
> >
> > problematic code
> > ---------------
> >
> > <datagridcolumn>
> >  <itemeditor>
> >  <component>
> >  <grid>
> >  <gridrow>
> >  <griditem>
> >  <combobox dataprovider="{outerDocument.data}" ... />
> >  </griditem>
> >  </gridrow>
> >  </grid>
> >  </component>
> >  </itemeditor>
> > </datagridcolumn>
> >
> > actionscript code
> > -----------------
> > object.data = ComboBox(event.currentTarget.itemEditorInstance).text;
> >
> > error in the action script code:
> > ---
> > cannot convert _inlinecompone...@3780479 to mx.controls.ComboBox
> >
> > Here the itemeditorinstance is a grid so, probably its not able to convert 
> > to combobox, how do we get the selected value of the combobox from the 
> > itemeditor ?
> >
> > I use the grid, as the rows are of variable height and the combobox looks 
> > huge if the height of the row is more
> >
> > Thank you
> >
> >
> >
> >
> >
> >
> > --
> > Alex Harui
> > Flex SDK Team
> > Adobe System, Inc.
> > http://blogs.adobe.com/aharui
> >
>






--
Alex Harui
Flex SDK Team
Adobe System, Inc.
http://blogs.adobe.com/aharui

Reply via email to