Should be same as for selectedItem in ComboBox.

 

    [Bindable("change")]

    [Bindable("collectionChange")]

    [Bindable("valueCommit")]

    Public function get selectedItemValue...

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of lucian_13_
Sent: Wednesday, March 14, 2007 5:16 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: BindableComboBox

 

I see no bindable metadata anywhere. How should it look? Thanks!

code:

<mx:ComboBox xmlns:mx="http://www.adobe.com/2006/mxml
<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>

--- In flexcoders@yahoogroups.com <mailto:flexcoders%40yahoogroups.com>
, "Alex Harui" <[EMAIL PROTECTED]> wrote:
>
> I haven't looked at it. Is BindableComboBox.selectedItemValue marked
> with [Bindable] metadata?
> 
> 
> 

 

Reply via email to