简体   繁体   English

SelectedLabel spark ComboBox

[英]SelectedLabel spark ComboBox

this function bellow returns the String for display in an item renderer. 此函数bellow返回String以在项呈示器中显示。

public function itemToLabel(item:Object):String

As selectedLabel property is obsolete in spark.components.ComboBox i added this function : 由于selectedLabel属性在spark.components.ComboBox已经过时,我添加了这个函数:

public function get selectedLabel():String 
    {
        var item:Object = selectedItem;
        return itemToLabel(item);
    }

But i am blocked about the public function set selectedLabel(label:String):void 但我被阻止public function set selectedLabel(label:String):void

is there anyone who know a function labelToItem or another solution to set my combobox selectedLabel 是否有人知道函数labelToItem或另一个解决方案来设置我的组合框selectedLabel

Not the most performant solution, but if you don't have a ton of items in the dataprovider then this should be alright: 不是最高效的解决方案,但如果你没有一吨的dataProvider项目的那么这应该是正常的:

public function setSelectedLabel(cb:ComboBox, label:String):void
{
    for each(var item:Object in cb.dataProvider)
    {
        if(item[cb.labelField] == label)
        {
            cb.selectedItem = item;
            return;
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM