3 Replies Latest reply on Oct 16, 2006 10:10 AM by GeorgeWS

    ComboBox

    GeorgeWS Level 1
      I have a grid that is filled in with data from a RemoteObject that I make an array out of. I want to have a combobox that gets its selections from the same RO. Is that the right way to go? Or do I need to make another RO that calls the CFC with just the selection data I want? Can someone show me what this would look like? I see lots of samples but cant seem to get anything to fill the ComboBox. Even if I use the original RO that fills the grid I cant get anything to display in the combobox. Im not sure how to call the array, or I should say just part or the array. The data fiels and one for the label.

      George
        • 1. ComboBox
          leotemp Level 1
          Well im not an expert but from my understanding as well as my working applications you dont need to convert your result to an array if your result is xml, it will be defaultly handled as an "XMLlist"

          Im not sure how your getting your result, if your using an HTTPservice then set your datagrid to use the HTTPservices last result, this way everytime the HTTPservice component is refreshed or used it will refresh the datagrid as well.

          Heres an example of the logic using the XMLlist result from the HTTPservice, lets say your result XML data is structured like this

          <xml>
          <flavors>
          <flavor>Chocolate</flavor>
          </flavors>
          <flavors>
          <flavor>Vanilla</flavor>
          </flavors>
          <flavors>
          <flavor>Squid</flavor>
          </flavors>
          </xml>

          Your ComboBox should look like this, Note that the dataprovider is pointed at the collection of "flavors". The text your want shown to the user is handled by "labelField" in this case "flavor", this will create one item for each item in the flavors collection and display the flavor as the text in the drop down.

          <mx:ComboBox dataProvider="{YourHTTPServiceID.lastResult.xml.flavors}" labelField="flavor">
          </mx:ComboBox>

          Your datagrid should look like this, note that the dataprovider points at the collection of "flavors" and then the "dataField" in the collumn reflects the desired value of "flavor" Also in this example there is a hidden collumn that contains the hypothetical ID or other possibly needed data you may have but dont want to be displayed to the user:

          <mx:DataGrid dataProvider="{YourHTTPServiceID.lastResult.xml.flavors}">
          <mx:columns>
          <mx:DataGridColumn headerText="Flavors" dataField="flavor" width="620"/>
          <mx:DataGridColumn dataField="ID" visible="false" />
          </mx:columns>
          </mx:DataGrid>

          Hope that helps clarify things a bit, if not, my bad.
          • 2. Re: ComboBox
            Diemos Level 1
            make sure you pull a field called data and one called label, rename the query field names on the select statement.
            • 3. Re: ComboBox
              GeorgeWS Level 1
              Thanks for the sample, I am using the RemoteObject. The XML is very different. Do you have a sample of a remote object to a combobox. wher the data would be like:
              BrandID BrandDesc
              1 Apples
              2 Oranges

              Thanks