Hi,
the field specified by the column in dataprovider for the datagrid is same as
the item in the dataprovider of the combobox
heres an example
dataprovider for datagird
{name: "sample project", status_type: "progress"}
dataprovider for combobox
{"hold","progress", "closed"}
the column field is status_type (string)
<datagrid itemEditEnd="editEnd(event)">
<columns>
<datagridcolumn dataField="name" />
<datagridcolumn dataField="status_type">
<itemeditor>
<component>
<box>
<combobox id="cbStat" dataProvider="{outerDocument.status}"
labelField="status_type" text="{data.status_type}"
selectedItem="{data.status_type}" />
</box>
</component>
</itemeditor>
</datagridcolumn>
</columns>
</datagrid>
<script>
private function editEnd(event:Datagridevent):void
{
var status =
event.currentTarget.itemEditorInstance.cbStat.selectedItem.status_type;
}
when I use the selectedItem="{data.status_type}", the selected value in the
combobox is shown right, but gives an error when I click out of the gird
If I change the value of the dropdown it gives an error:
"Property text not found on filename_inlineComponent2 and there is no default
value."
tried debugging and see that these errors occur in the DataGrid.as file line
no: 4827
var newData:Object =
itemEditorInstance[_columns[event.columnIndex].editorDataField];
If I do not change the value of the combobox and click out of the grid, the
error:
"Cannot access a property or method of a null object reference."
error at this line in the script
var status =
event.currentTarget.itemEditorInstance.cbStat.selectedItem.status_type;
the same code works fine, if I don't have a box around the combobox, no issues
at all
is there something I am missing out when using a inner components
Thank you,
Goutham
--- In [email protected], Alex Harui <aha...@...> wrote:
>
> 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" <goldensu...@...> 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" <goldensuits@> 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
>