6 Replies Latest reply on Feb 3, 2011 11:53 AM by Jerry62712

    How do I select a combo-box member?

    Jerry62712 Level 1

      First, yes, I have done a search in the forum for this topic.  I just didn't find an answer I understand.

       

      I have a control, a combobox:

                      <DHSCntl:rightLabel id="dtSODCFI"
                          label="SODC:"
                          required="true"
                          labelWidth="135"
                          indicatorGap="14">
                          <mx:ComboBox id="dtSODC"
                              dataProvider="{SODCName}"
                              tabIndex="10"
                              change="dtFormUpdated()"/>
                      </DHSCntl:rightLabel>

       

      I have an XML string that will represent a person and that person will have a specific SODC in this case.  I tried several combinations such as:

      dtSODC.text = XMLrecord.SODC;

      dtSODC.data = XMLrecord.SODC;

      and a few others.

       

      None of them seemed to work.  The way that does is to have a function that will return an index number and then set the control's index to that.  But that requires code to match the combobox and I don't like the idea of duplicate code.  I use it because a simple way isn't presenting itself.

        • 1. Re: How do I select a combo-box member?
          miguel8312 Level 3

          its the xml in your project? where are you getting the xml from.

          You should look at the URLLOADER for this type of thing then loop through values and add to your dataprovider.

          are you doing all that?

          Miguel

          • 2. Re: How do I select a combo-box member?
            Jerry62712 Level 1

            We get the XML from LiveCycle which gets data from an SQL Database.  I can see the XML in the debugger watched expressions and it looks OK.  It works with the function that finds the index of the value.  But there has to be a more simple method to get to the results.

            • 3. Re: How do I select a combo-box member?
              Flex harUI Adobe Employee

              You should be able to set the selectedItem to the XML node.

              • 4. Re: How do I select a combo-box member?
                Jerry62712 Level 1

                When I use this:

                        compDT.dtSODC.selectedItem = XMLRecord.SODC;
                where the value of XMLRecord.SODC is "Choate" I see this:

                 

                compDT.dtSOCD

                ...

                     selectedItem

                          [0] = XML

                               <SODC type="nvarchar">

                                    "CHOATE"

                                    <mx_internal_uid>

                ...

                 

                I would have expected to see just the value.  Is there something I should put on the XML side like ".text" or ".value"?

                • 5. Re: How do I select a combo-box member?
                  Flex harUI Adobe Employee

                  Almost all XML "queries" return an XMLList.  The debugger and trace will

                  sometimes coerce an object to a String.  Are you trying to match against a

                  String in the ComboBox's dataProvider?  If so, try

                      compDT.dtSOCD.toString()

                  1 person found this helpful
                  • 6. Re: How do I select a combo-box member?
                    Jerry62712 Level 1

                    Belated (we were off yesterday) thanks.

                     

                    What I found was the XML assignment was moving the XML node including the openning tags.  To get around that, I changed it to:

                            compDT.dtSODC.selectedItem = XMLRecord.SODC.toString();

                     

                    Unfortunately, Flex won't provide any code assist with the XML side so I had to just go on faith that it would work (using the toString method with XML).  Fortuantely, it does work.

                     

                    This eliminated a call to a function to test input values against a bunch of "if" statements and assigning a number (the index of the dropdown box) to a variable used later with the selectedIndex property.  More importantly, it eliminates the need to have the array duplicated in the array and "if" statement form.  Now there is only one place to have the data entered and the rest just happens.

                     

                    In the other controls the ".text" seems to take care of the conversion from an XML notation to a string one.