开发者

Populate comboBox in flex 4 using remote Object

开发者 https://www.devze.com 2023-02-15 05:06 出处:网络
I have a remote object returned and I am trying to populate it into combobox. <s:RemoteObject id=\"ro\" result=\"result(event)\" destination=\"echoServiceDestination\">

I have a remote object returned and I am trying to populate it into combobox.

<s:RemoteObject id="ro" result="result(event)" destination="echoServiceDestination">

private var statesData:ArrayCollection;

private function result(e:ResultEvent):void{
   statesData = e.result as  ArrayCollection;

}

How can I turn this c开发者_如何学JAVAollection into something like {label:"Red", data:"#FF0000"} so that I can populate into combobox

The remote object is party and I can't seem to able to cast it as below

                  var party:Party = new Party;

            for(var i:int = 0 ; i < statesData.length; i++)
            {
                party = statesData.getItemAt(i);    

            }

Thanks for the help.


You need to implement a label function. Set the returning data directly as dataprovider to your combobox:

<mx:ComboBox id="comboBox"

            dataProvider="{statesData}"
            labelFunction="labelFunc" />

This will be your label function:

        private function labelFunc(item:Object):String {
            return item.label; // Or whatever parameter you want to display
        }
    ]]>
</mx:Script>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号