views:

91

answers:

1

Hi All

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

+2  A: 

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']
}
www.Flextras.com
Dag Nabbit! Beaten to the punch again by Flextras.com!
Marty Pitt
I'll race you to the next one. :-)
www.Flextras.com
Wow you are a life saver...Thank you!!! - Harish
Harish
@Harish Glad to help! If you feel this actually solves your problem, be sure to accept it by clicking the 'check'. I'd appreciate the karma points.
www.Flextras.com