Flex DropdownList does not show the correct values

眉间皱痕 提交于 2019-12-11 17:14:27

问题


I have a Flex Spark dropdownList in which I need to show the Provider FirstName,LastName:

   <s:DropDownList id="providerList"
            dataProvider="{model.practiceProviderList.practiceProviders}"
    labelField="provider.providerName.firstName"/>

But the output shows only [object Object] & [object Object] as there are 2 providers in the DB and does not show the actual values.

The PracticeProviderList.as:

[Bindable]
    [RemoteClass(alias="model.PracticeProviderList")]
    public class PracticeProviderList extends PracticeProviderListBase {

        private var _practiceProviderList:ArrayCollection;

        public function get practiceProviders():ArrayCollection
        {
            return _practiceProviderList;
        }

        public function set practiceProviders(value:ArrayCollection):void 
        {
            _practiceProviderList = value;
        }

The PracticeProvider Object:

public class PracticeProvider  {

        private var _practiceId:Number;
        private var _practiceProviderId:Number;
        private var _provider:Provider;

        public function set practiceId(value:Number):void {
            _practiceId = value;
        }
        public function get practiceId():Number {
            return _practiceId;
        }

        public function set practiceProviderId(value:Number):void {
            _practiceProviderId = value;
        }
        public function get practiceProviderId():Number {
            return _practiceProviderId;
        }

        public function set provider(value:Provider):void {
            _provider = value;
        }
        public function get provider():Provider {
            return _provider;
        }

The Provider has providerName:PersonName as one of it's fields & PersonName has firstName:String & lastName:String

I need to show the First Name, Last Name in the dropdownlist. I would appreciate if someone can help in this regard.

Thanks

Harish


回答1:


The labelField can't concatenate 2 values. Use a labelFunction instead.

If I understand your data model, Something like this:

public function myLabelFunction(item:Object):String{
 return item['providerName']['PersonName']['firstName'] + ' ' + item['providerName']['PersonName']['lastName']
}


来源:https://stackoverflow.com/questions/3660479/flex-dropdownlist-does-not-show-the-correct-values

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!