4 Replies Latest reply on Jan 26, 2011 2:47 AM by perflexed

    Combobox, itemRenderer, Label not displaying

    perflexed Level 1

      Hi,

        So I have a combox control in a project, the combobox's dataprovider is populated by data that comes from a webservice.

      The problem I am having right now is that the Labels in the dropdown are not visible when one 'opens' the combobox. However, when one selects one of the items form the list, the 'selected item' text is displaying correctly.

       

        This is an old flex 3 project so that might be relevant.

        Here is some of the code...

       

        In my main.mxml file I define the combobox like so:

      <mx:ComboBox x="34" y="366" id="projectSelect" dataProvider="{projects}" itemRenderer="renderers.ComboBoxItemRenderer" change="findMessageCategory()" prompt="Please select a project"/>

       

      In one of my scripts I pull the data for projects from a webservice and build projects like so:

      projects = new ArrayCollection();

      for(var count:int = 0; count < temp.length; count++)

      {

           projects.addItem({label:temp.getItemAt(count).name,id:temp.getItemAt(count).id});

      }

       

      The dropdown has 3 (invisible) rows which is the correct number of results being returned from the web service.

      The ComboBoxItemRenderer.mxml file looks like this:

      <?xml version="1.0" encoding="utf-8"?>

      <!-- http://blog.flexexamples.com/2007/09/25/creating-a-custom-combobox-item-renderer-in-flex/ -->

      <mx:HBox xmlns:mx="http://www.adobe.com/2006/mxml">

      <mx:Label text="{data.label}" width="100%"/>

      </mx:HBox>

       

      So does anyone have any ideas what I am doing wrong here?

      I have tried setting the color of the Label to #000000 explicitly but that doesn't make any difference.

      If I put some images into ComboBoxItemRenderer they do appear, so the app does appear to be using my custom item renderer.

      I am stumped!

        • 1. Re: Combobox, itemRenderer, Label not displaying
          ritesh_gcet

          Dear perflexed,

           

          i have created the application as  taken input ur code, in main.mxml code is

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application

           

           

          xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="onLoad();">

          <mx:Script>

          <![CDATA[

           

          import mx.collections.ArrayCollection;

          [Bindable]private var projects:ArrayCollection= new ArrayCollection();

           

          private function onLoad():void

          {

          projects

           

          new ArrayCollection()

           

          for(var count:int = 0; count < 4; count++)

          {

          projects.addItem({label:

          Text+count.toString()});

           

          }

          }

          ]]>

          </mx:Script>

           

           

          <mx:ComboBox x="34" y="366" id="projectSelect" dataProvider="{projects}"

          itemRenderer="

          cbRenderer" prompt="Please select a project"/>

          </mx:Application>

           

          the Item render code is

          <?xml version="1.0" encoding="utf-8"?>

           

          <mx:HBox

           

          xmlns:mx="http://www.adobe.com/2006/mxml">

           

          <mx:Label

           

          text="{data.label}" width="100%"/>

           

          </mx:HBox>

          but i have not got that error. pls check is it OK??

           

          1 person found this helpful
          • 2. Re: Combobox, itemRenderer, Label not displaying
            perflexed Level 1

            Hi,

              I can run your example just fine, but it doesn't really shed any light on what I'm doing wrong unfortunately.

            I've tried using a VBox instead.

            I am explicitly setting the color property, visible=true etc etc.

            I've tried setting the width and height of the label and the vbox in case my label was being clipped or something, but no luck.

            I have noticed that when I hover over the rows in the dropdown I do see the 'tooltip' label text correctly.

            So frustrating!

            • 3. Re: Combobox, itemRenderer, Label not displaying
              Flex harUI Adobe Employee

              Can you reproduce the problem in 20 lines of MXML?  If so, post the test

              case.  Use fake data instead a webservice.

              • 4. Re: Combobox, itemRenderer, Label not displaying
                perflexed Level 1

                Hi,

                  Ok, I have solved the problem.

                I am using flash builder 4. The project was originally written using flex builder, i.e. flex version 3.

                So I had my compiler set to use sdk version 4.1 with version 3 compatibility mode.

                I had it set this way as I am using borderThickness a lot and this was generating lots of errors when I first started the project again.

                So when I took the version 3 compatibility mode off, and set the theme to Halo (to get rid of the borderThickness errors) suddenly I could see my combo box!

                Weird but there you go.

                Now if only I had thought of that before wasting 12 hours of my life trying to fix this...