views:

736

answers:

1

Hi,

how to bind array object to combo box in Air application..

i have array of objects from that i need to bind name property to the label field of combobox how to do that ?

var objk:Array=objkparent.children; // it return object collection comboBox.dataProvider=objk; comboBox.labelField=objk.name;

but its not working how to bind it...?

A: 

Are you sure that the elements in objk array have a field called name? I tried the following which seems to work.

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:Script>
 <![CDATA[  
   [Bindable]
   private var daStates:Array = [
         { name:"Arizona", label:"AZ" },
         { name:"Tennessee", label:"TN" },
         { name:"New York", label:"NY" }
   ];
 ]]>
</mx:Script>


<mx:Panel layout="absolute" title="Stack Overflow" id="panel" height="100%" width="100%">
    <mx:Form id="daForm">
     <mx:FormHeading label="Just a demo" />
     <mx:FormItem label="Combo Box">
      <mx:ComboBox dataProvider="{daStates}" labelField="name" />
     </mx:FormItem>
    </mx:Form>
</mx:Panel>

Also, in general its better to use ArrayCollection rather than Array when binding is involved.