5 Replies Latest reply on Feb 9, 2010 10:58 PM by Francisc

    Width problem

    RUSH-ME Level 3

      Hi folks


      In my application I used a combobox and I set the width="100%". When I am giving data with big text the combobox is resizing and works fine. But if the data to the combobox is blank, combobox is using its default width. which is very large to me. so I reduced the width by setting the width property to some value.


      However, again passing data with big text, the combobox is not resizing.

      Any thoughts?


      Warm Regards


        • 1. Re: Width problem
          Francisc Level 3

          I had the same problem.


          What I did was give it a specific width, like 150.


          - OR -


          Give it the width of it's parent container: width="{cbParent.width}"


          Where cbParent is the parent container of the ComboBox, e.g. a VBox, an HBox, a Canvas etc

          • 2. Re: Width problem
            RUSH-ME Level 3



            using width will not solve my problem necause i want the combobox to resize according to data. But if there is no data it should be take very small width.



            • 3. Re: Width problem
              archemedia Level 4

              It's just a trick, but it works:


                    public var cbp:ArrayCollection = new ArrayCollection([{label: ""}]);




              <mx:ComboBox dataProvider="{cbp}"/>




              1 person found this helpful
              • 4. Re: Width problem
                Francisc Level 3

                Dany's idea will work.

                You can also try: <mx:ComboBox prompt="" selectedIndex="-1"/>


                Or you can do it programatically: if the dataProvider is empty, set width to X1, if it isn't set it to X2. You can also try maxWidth to give it room to resize up to a point if you want.

                • 5. Re: Width problem
                  Francisc Level 3

                  For the programatic approach you can do something like this for example:


                  <mx:ComboBox width="{(myDataProvider==null || myDataProvider.length=0?100:200)}"/>


                  Means if the dataProvider is null or lenth is 0 (just to make sure), set the width to 100, otherwise set it to 200.


                  Make sure the myDataProvider variable is bindable, otherwise you won't see the resize 'live'.