The ComboBox list is driven by a dataProvider, which can be a collection
of complex objects.  You can specify the labelField to be whatever
property in the dataProvider item object you want.

 

When an option is selected, you can access the entire selected item by
using ComboBox.selectedItem.  You can then access whatever property you
want.

 

The problem is that the standard ComboBox only allows setting
selectedIndex.  So if there is a value in the mainDG item that you need
to have the ComboBox display, you have to loop through the CBO
dataProvider, and compare that value to the corresponding property in
the ComboBox dataProvider item.  When you find a match, you can use the
loop index to set the selectedIndex.

 

To make this happen in a dataProvider, you have to run that select
search loop from the set data or commitProperties override.

 

I have posted an example of this recently, and ther is a copy posted
here:

http://www.cflex.net/showfiledetails.cfm?ChannelID=1&Object=File&objectI
D=767

 

That example allows for row level differences in the ComboBox
dataProvider, or you can have a static list at the parentDocument level.


 

That particular example uses simple values for the CBO dataProvider, but
using a complex object should be little different.

 

Tracy

 

 

 

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of arashafrooze
Sent: Thursday, November 29, 2007 4:29 PM
To: [email protected]
Subject: [flexcoders] Re: ComboBox inside a DataGrid

 

ok
so you know how when u have an html select box, each option has a
value and display? like <option value='1'>One</option>

ok so I want the same thing. I want the combobox to display something
but onchange submit a value. so for example the combobox would display
"One" but when submitted it submits "1".
Now this "1" is tied to an attribute of a User Object.
each row of my datagrid represents a user object and each user object
has a "role_id" attribute. 
My combobox's dataprovider is a static list of all possible roles and
i want the option with the user's "role_id" to be selected. but it
cannot display the role_id, but must display the role_label.
How do i do this?

it probably doesnt make much sense. grrr i hate having to type this out.

--- In [email protected] <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> Not sure I understand. The ComboBox usually represents one of a set of
> possible values for a datafield in a dataprovider. Can you give a more
> explicit example of the data involved?
> 
> 
> 
> ________________________________
> 
> From: [email protected] <mailto:flexcoders%40yahoogroups.com>
[mailto:[email protected] <mailto:flexcoders%40yahoogroups.com>
] On
> Behalf Of arashafrooze
> Sent: Thursday, November 22, 2007 9:47 AM
> To: [email protected] <mailto:flexcoders%40yahoogroups.com> 
> Subject: [flexcoders] ComboBox inside a DataGrid
> 
> 
> 
> Hi everyone,
> I have a datagrid and I'd like to add a comboBox under one of the
> columns. Now apparently I have to specify a dataField for my
> DataGridColumn, but I want the data for this column to come from my
> combo box. How do i do that?
> Im pasting a piece of the code here to make more sense:
> 
> <mx:columns>
> <mx:DataGridColumn headerText="First Name" dataField="first_name"
> editable="false" />
> 
> <mx:DataGridColumn headerText="Last Name" dataField="last_name"
> editable="false" />
> 
> <mx:DataGridColumn headerText="User Name" dataField="login"
> editable="false" />
> 
> <mx:DataGridColumn headerText="Branch" dataField="branch"
> editable="false" />
> 
> <mx:DataGridColumn headerText="Role" dataField="role">
> 
> <mx:itemEditor>
> <mx:Component>
> <comp:ExtendedComboBox
> dataProvider="{UserList.modelLocator.roles}" dataField="id"
> labelField="name" id="RoleSelector" />
> </mx:Component>
> </mx:itemEditor>
> 
> </mx:DataGridColumn>
> </mx:columns>
> 
> I got the extendedComboBox from ben forta's blog at :
>
http://www.forta.com/blog/index.cfm/2006/11/22/Flex-ComboBox-With-select
<http://www.forta.com/blog/index.cfm/2006/11/22/Flex-ComboBox-With-selec
t> 
> edValue-Support
>
<http://www.forta.com/blog/index.cfm/2006/11/22/Flex-ComboBox-With-selec
<http://www.forta.com/blog/index.cfm/2006/11/22/Flex-ComboBox-With-selec
> 
> tedValue-Support> 
> 
> thank you guys,
> 
> -A
>

 

Reply via email to