You might find this article helpful:

http://blogs.adobe.com/aharui/2008/01/selecteditem_and_combobox.html

 

That way you can find the item you want to be selected after the DP is
set.  In general the DP must be set first.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of mark goldin
Sent: Friday, January 04, 2008 3:42 AM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Setter question

 

Yes, that's what I fugured.

Here is my code. 

I have a combobox as a form item.:

<mx:FormItem

label="Other RailRoad Involved" width="302"> 

<customComponents:comboItemRenderer 

selectedIndex="

{modelGeneral.otherrailroadinvolved}" 

id="

otherrailroadinvolved" width="95"! > 

</customComponents:comboItemRenderer> 

</mx:FormItem> 

dataModel tag: 

<moduleCode:accidentsGeneralModel

id="modelGeneral"/> 

 

Data Model:

public

class accidentsGeneralModel 

{

private var _otherrailroa! dinvolved:int = 0; 

[

Bindable] 

public var modelValid:Boolean = false; 

  

[

Bindable] 

public function get otherrailroadinvolved():int 

{

return! _otherrailroadinvolved; 

}

public function set
otherrailroadinvolved(otherrailroadinvolved:int):void 

{

_otherrailroadinvolved = otherrailroadinvolved;

}

Combo's data:

combo.dataProvider = someXML;

 

Form's data:

//reference to main application

mainApp = mx.core.Application.application;

// reference to A! ccidents module 

accidentsModul! e = main App.moduleLoader.child;

accidentsModule.modelGeneral.otherrailroadinvolved =
resultXML.general.otherrailroadinvolved;

 

Here is what happens:

If I am setting up form's data after combo's dropdown has been set then
the combo will show the correct item: item that is driven by the form's
data. But if I do it other way around then the combo does not show the
correct one but always has its selectedIndex = 0.

I am trying to override dataProvider property but dont know what I can
match combo's dropdown data to to set its selectedIndex manually.

 

Thanks


Alex Harui <[EMAIL PROTECTED]> wrote: 

Unless comboItemRenderer is in a List or DataGrid or other
ListBase-derived class, the listData setter function will not be called.

Assigning the combo's dataprovider just tells its dropdown List what to
display.

________________________________

From: flexcoders@yahoogroups.com [mailto:flex! [EMAIL PROTECTED] ahoogroups.com]
On Behalf Of mark goldin
Sent: Thursday, January 03, 2008 6:17 PM
To: flexcoders@yahoogroups.com
Subject: RE: [flexcoders] Setter question

Combo:

package! 

CustomComponents 

{

import mx.controls.*; 

import mx.controls.listClasses.*; 

import mx.collections.*; 

import flash.events.Event; 

import mx.events.*; 

public class comboIte! mRenderer extends ComboBox implements
IDropInListItemRenderer 

{

public function! comboItemRenderer() 

{ 

super(); 

}

override public function set listData(value:BaseListData):void 

{

super.listData = value; 

......

Assigning data:

combo.dataProvider = XMLData;

Should I be getting into listData function after that command?


Gordon Smith <[EMAIL PROTECTED]> wrote: 

What do you mean by defining a "set function" for the ComboBox? Can you
show some code?

! 

Gordon Smith

Adobe Flex SDK Team

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of markgoldin_2000
Sent: Thursday, January 03, 2008 5:44 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Setter question

I have a combobox in a form. I have also defined a set function for 
that combo. I am assigning data to the control using:
combo.dataProvider = someXML. The data is shown with no problem, but 
set function is not called. Am I doing something wrong?

Thanks

 

 

Reply via email to