4 Replies Latest reply on Nov 6, 2007 1:11 PM by ntsiii

    comboBox issue

    Level 7
      Hi All,
      I'm adding the elements of my comboBox dinamic, I can't add a Zero element
      because it will show in my datagrid that I'm selecting my element.
      If I add only one element on my comboBox I can't select that element, I have
      to add another one and then select that and go back to the first one in a
      way to be selected.
      Any way I can fix this issue?
      Thanks in advance.
      JFB


        • 1. Re: comboBox issue
          Haravikk the Horse
          I'm assuming that your use-case is along the lines of:
          - You have a combo-box with elements A, B, C.
          - You select B, something happens.
          - You now add a fourth element, D.
          - You attempt to select B but it's already selected, so nothing happens.

          Typical solution to that would be to have a 'title' element at the top, something like "Select", whose value is null (so that your datagrid can ignore it).
          Then, whenever you add/remove/modify elements in your combo-box, you set it's selection to the 'title'. This helps indicate to the user that something has changed, and the use of a title also serves a way of indicating what the option does, for example if the title is "Select category" then the user knows it is for selecting a category.

          If this is not the case you are trying to describe then please do post a step-by-step use-case for your problem (code is not required, just a description in simple steps) then that would help, as it's easier to understand what you're doing.
          • 2. Re: comboBox issue
            Level 7
            Thanks for you reply...
            I keep playing with this and I see that it's always a problem at start

            public function setMailshopFilter(event:Event):void{
            Alert.show(material_cb.selectedItem.materialsItemID.toString();)
            }
            <mx:ComboBox id="material_cb" dataProvider="{acMaterials}"
            labelField="materialsItem" x="10" y="32" width="278"
            change="setFilter(event)" />.
            Fill my comboBox with an arrayCollection with elements A,B,C,D
            Click on my ComboBox and try to select A.... doesn't do anything.
            Click and select B ... display ID
            Go back and click A ... display ID

            How can I correct this issue?
            Tks
            JFB


            "Haravikk the Horse" <webforumsuser@macromedia.com> wrote in message
            news:fgq78s$ei6$1@forums.macromedia.com...
            > I'm assuming that your use-case is along the lines of:
            > - You have a combo-box with elements A, B, C.
            > - You select B, something happens.
            > - You now add a fourth element, D.
            > - You attempt to select B but it's already selected, so nothing happens.
            >
            > Typical solution to that would be to have a 'title' element at the top,
            > something like "Select", whose value is null (so that your datagrid can
            > ignore
            > it).
            > Then, whenever you add/remove/modify elements in your combo-box, you set
            > it's
            > selection to the 'title'. This helps indicate to the user that something
            > has
            > changed, and the use of a title also serves a way of indicating what the
            > option
            > does, for example if the title is "Select category" then the user knows it
            > is
            > for selecting a category.
            >
            > If this is not the case you are trying to describe then please do post a
            > step-by-step use-case for your problem (code is not required, just a
            > description in simple steps) then that would help, as it's easier to
            > understand
            > what you're doing.
            >


            • 3. Re: comboBox issue
              ntsiii Level 3
              Try setting selectedIndex="-1".

              Also, you might look at the "click", "close", and "valueCommit" events.

              Tracy
              • 4. Re: comboBox issue
                ntsiii Level 3
                Also, use the "prompt" property to display a string, like, "Select Value", in the cbo. It will only display when there is nothing selected, and will not be part of the dataProvider.

                Tracy