3 Replies Latest reply on Apr 14, 2009 9:49 PM by Michael Borbor

    ComboBox

    GeorgeWS Level 1
      I have been trying for days. Read Ben Fortas blog looks good but does not seem to work for me.
      I have a Default component that calls in a component that has a datagrid filled by a RemoteObject. When I select a row all of the selections appear in my detail component. {selectedItem.state} etc. I try and use this to have a combobox get selected with the correct state. But the only part of the Combobox that actually works is the selectedIndex. But I dont have the index I have the state name and a state code. How can I use the statecode to select the correct state that was picked from the datagrid? I am looking at the slectedItem but do not know what the values are for that in the combobox. What a pain, why is this not build into the component?

      Thanks
      George
        • 1. Re: ComboBox
          Gregory Lafrance Level 6
          This may help:

          cbx.selectedIndex = ac.getItemAt(ac.getItemIndex(theObject));

          • 2. Re: ComboBox
            GeorgeWS Level 1

            I am still stumped. selectedItem does not work no mater what I do, even setting the variable does not work. I have a DG in a component and its easy to show on another component <mx:label text="{selectedItem.statecode}"/> When I press on a record in the DG the label gets filled in with the state code. But this does not work with the combobox. If I use selectedIndex the combobox changes but seems to be random. I have even tried using a 2nd RO with the same query so that the index's would be the same but they are not. Its a bummer it takes days, now into weeks to figure out, should be built in to the component. 

            I dont see how the statement you showed me gets fired?

            • 3. Re: ComboBox
              Michael Borbor Level 4

              Hi there, I don't know if this is what you're looking for, I created an AIR here's the code for it.

               

              <?xml version="1.0" encoding="utf-8"?>
              <mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:Comps="*">
              
                   <mx:HDividedBox>
                        <mx:ComboBox dataProvider="{myCustomComp.myAC}" selectedIndex="{myCustomComp.myGrid.selectedIndex}" labelField="Month" />
                        <Comps:testComp id="myCustomComp" x="181" y="27">
                        </Comps:testComp>
                   </mx:HDividedBox>
                   
              </mx:WindowedApplication>
              

              And then a mxml component that it's in the same folder as the application file

               

              <?xml version="1.0" encoding="utf-8"?>
              <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml" width="400" height="300">
                   <mx:Script>
                        <![CDATA[
                             import mx.collections.ArrayCollection;
                             
                             [Bindable]
                             public var myAC:ArrayCollection=new ArrayCollection([
                      {Month:"Jan", Profit:2000, Expenses:1500, Amount:450},
                      {Month:"Feb", Profit:1000, Expenses:200, Amount:600},
                      {Month:"Mar", Profit:1500, Expenses:500, Amount:300}]);
                             
                        ]]>
                   </mx:Script>
                   
                   <mx:DataGrid dataProvider="{myAC}" id="myGrid">
                        
                   </mx:DataGrid>
              </mx:HBox>
              
              

               

              I think this app does what you want, I hope it could help you solve your issue.