2 Replies Latest reply on Mar 15, 2007 8:29 AM by dennismr

    Combo Box data value

      I have a combo box that I've populated with a DataProvider call to a web service. The only value I've been able to display and access is the LabelField property. That allows me to display appropriate information in the box but I don't see how to access data from the web service that I wouldn't want to display in the drop down display. Is it possible to get more information than just the one field?
        • 1. Re: Combo Box data value
          Brandon Ellis Level 1
          Depending on the result format of your data (pretty much they all come down to objects) you should be able to to call your data with the property name:
          <?xml version="1.0" encoding="utf-8"?>
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="init();">

          import mx.collections.XMLListCollection;
          import mx.controls.Alert;

          private var myXML:XML = <contacts>

          private var ary:Array;
          private var xmlCol:XMLListCollection;

          private function init():void {
          xmlCol = new XMLListCollection(myXML.contact);
          contactCB.dataProvider = xmlCol;
          contactCB.addEventListener("change", contactCBChangeHandler);

          private function contactCBChangeHandler(evt:Object):void {
          Alert.show(evt.target.selectedItem.name + " is from " + evt.target.selectedItem.state);
          <mx:ComboBox x="64" y="20" id="contactCB" labelField="name"></mx:ComboBox>

          Since I made up the datasource I used the XMLListCollection to hold the xmlList (myXML.contact). myXML.contact is actually an object array and can be thought of in the way:
          var ary:Array = new Array(
          {name:"Brandon", state:"Virginia"},
          {name:"Mark", state:"Georgia"}l
          {name:"John", state:"Texas"}

          Just keep in mind that the object properties are the xml node names returned from your service.

          I know this isn't the greatest example but it's late.
          hope it helps some anyway.
          • 2. Re: Combo Box data value
            dennismr Level 1
            Awesome, thanks very much! I'll try this out and let you know.