Wei! Ni hao.  So, my $0.02 on this is to stear away from all the
bindable dependencies and use AS instead. Set a handler for the change
event on your master combo and set the selectedItem on the detail
combo manually.

The behaviour you describe may very well be timing issues. Binding one
may fire slightly after/before binding two causing this sort of thing.
Even manually setting things as suggested above can display this
behaviour. You'll need to make use of commitProperties() at that
point.

DK

On 5/4/09, Chang, Shyue-jing <[email protected]> wrote:
> Hi,
>
> Does anyone know how to bind the selectedItem of a combobox? Currently I am
> having problems trying to bind the selectedItem of a bindable combox in a
> master/detail app.  Here is my code for the combobox:
>
> <mx:FormItem id="relationshipFormItem" label="Relationship to XX"
> fontWeight="bold">
>       <view:BindableComboBox id="relationshipCB" width="123"
>               dataProvider="{model.relationships}"
>               valueField="relationshipCode"
>               labelField="relationshipDesc" enabled="true"
>                 selectedItem="model.selectedGuest.relationship}" />
> </mx:FormItem>
>
> I would like to have the selectedItem bind to the relationship of the
> selectedGuest when a guest is selected form the master list. When a guest is
> selected from the master list, the selectedGuest in the model is set to the
> guest selected and the state in the model is set to the detail state.  Both
> relationships and guest are bindable value objects.
>
> 1. the "relationships" value object has two properties relationshipCode and
> relationshipDesc
> 2. the guest value object that has a relationship property (which is a
> string that corresponds to the relationshipCode of the relationships VO)
> plus other properties.
>
> What happened was that the selectedItem sometimes bind correctly to the
> relationship of the selected guest, but sometimes did not bind and the first
> value in the drop down box (null) was displayed.  I even had two exact
> comboboxes (with different ids) and sometimes one did bind and the other
> not.
>
> Can someone shed some lights on this?  Any help will be deeply appreciated.
>
> Susan
>
> This is the code of the BindableCombox I used (provided by the code
> generator for coldfusion/flex)
>
> BindableCombobox (provided by code generator for coldfusion/flex):
>
> <?xml version="1.0" encoding="utf-8"?>
> <!--
> ////////////////////////////////////////////////////////////////////////////////
> //
> //  Copyright (C) 2003-2006 Adobe Macromedia Software LLC and its licensors.
> //  All Rights Reserved. The following is Source Code and is subject to all
> //  restrictions on such code as contained in the End User License Agreement
> //  accompanying this product. If you have received this file from a source
> //  other than Adobe, then your use, modification, or distribution of this
> file
> //  requires the prior written permission of Adobe.
> //
> //  @author Dean Harmon
> //  @author Mike Nimer
> ////////////////////////////////////////////////////////////////////////////////
> -->
> <mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml"; xmlns="*"
> creationComplete="componentInit()">
>     <mx:Script>
>         <![CDATA[
>             import mx.utils.ObjectUtil;
>             import mx.controls.Alert;
>
>             [Bindable]
>               public var valueField:String = "";
>       
>               [Bindable]
>               public var labelFields:Array = [];
>
>                       public function componentInit():void
>                       {
>                               this.labelFunction = renderLabelFunction;
>                       }
>                       
>                       public function renderLabelFunction(item:Object):String
>                       {
>                               var result:String = "";
>                               if (labelFields.length == 0)
>                               {
>                                       if (labelField != null)
>                                       {
>                                               return item[labelField];
>                                       } else {
>                                               return item.toString();
>                                       }
>                               } else {
>                               
>                                       for(var i:int=0; i < 
> labelFields.length; i++)
>                                       {
>                                               if (i > 0)
>                                               {
>                                                       result += " ";
>                                               }
>                                               
>                                               result += item[labelFields[i]];
>                                       }
>                               }
>                               return result;
>                       }
>
>                       override public function set 
> selectedItem(val:Object):void
>                       {
>                               //Alert.show(valueField +":" 
> +ObjectUtil.toString(val));
>                               if( this.valueField != null )
>                               {
>                                       for(var i:int=0; i < 
> this.dataProvider.source.length; i++)
>                           {
>                               var item:Object = this.dataProvider.source[i];
>               
>                               if( item[valueField] == val )
>                               {
>                                   // if it matches, make it selected.
>                                   this.selectedIndex = i;
>                                   break;
>                               }                       
>                           }
>                          }    
>                          else
>                          {
>                                       super.selectedItem(val);
>                          }                    
>                       }
>                       
>                       public function get selectedItemValue():Object
>                       {
>                               if( this.valueField != null && selectedItem != 
> null)
>                               {
>                                       return selectedItem[valueField];
>                               } else {
>                                       return text;
>                               }
>                       }
>
>         ]]>
>     </mx:Script>
> </mx:ComboBox>
>
>
>
>
>
> -------------------------------------------------------------
> To unsubscribe from this list, simply email the list with unsubscribe in the
> subject line
>
> For more info, see http://www.affug.com
> Archive @ http://www.mail-archive.com/discussion%40affug.com/
> List hosted by http://www.fusionlink.com
> -------------------------------------------------------------
>
>
>

-- 
Sent from my mobile device

Douglas Knudsen
http://www.cubicleman.com
this is my signature, like it?


-------------------------------------------------------------
To unsubscribe from this list, simply email the list with unsubscribe in the 
subject line

For more info, see http://www.affug.com
Archive @ http://www.mail-archive.com/discussion%40affug.com/
List hosted by http://www.fusionlink.com
-------------------------------------------------------------


Reply via email to