3 Replies Latest reply on Dec 29, 2010 2:05 AM by BhaskerChari

    Flex 3 : Combobox property data isn't being recognized

    kiran7881 Level 1

      Hi ,

       

      Why is that Combobox property data isn't being recognized  ??

       

      I have a Simple Combo box , under chnage event of that , a function is being getting called and under this combobox.data is not reflecting ??

       

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

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:Array id="myarray">
      <mx:String>One</mx:String>
      <mx:String>Two</mx:String>
      <mx:String>Three</mx:String>
      </mx:Array>

      <mx:Script>

      <![CDATA[
        import mx.controls.Alert;
       
        public function label1_creationCompleteHandler(event:Event):void
        {
        
         if(mycombobox.data>1)
                      {
                       Alert.show('Hi');
                          mycombobox.setStyle('backgroundColor','#137EC2');
                      }
        }
       
      ]]>
      </mx:Script>
      <mx:ComboBox id="mycombobox" dataProvider="{myarray}" creationComplete="label1_creationCompleteHandler(event)">
      </mx:ComboBox>
      </mx:Application>

        • 1. Re: Flex 3 : Combobox property data isn't being recognized
          IlyaG Level 1

          it doesn't have this property, you can try using contentBackgroundColor or chromeColor

          • 2. Re: Flex 3 : Combobox property data isn't being recognized
            kiran7881 Level 1

            Unfortunately , the answer is no where related to my question .

             

            First of all , ConboBox Component has got data property with in it .

             

            And I am thinking why my ComboBox.data  is not entering in this condition ??

             

            if(mycombobox.data>1)
                            {
                             Alert.show('Hi');
                                mycombobox.setStyle('backgroundColor','#137EC2');
                            }
              }

            • 3. Re: Flex 3 : Combobox property data isn't being recognized
              BhaskerChari Level 4

              Hi Kiran,

               

              You shouldn't use the data property in this context. It real purpose comes in to picture when you are working/using itemRenderers or itemEditors.

               

              More over the condition if(mycombobox.data>1) will not be satisfied why because your mycombobox.data equals to null value and hence the condition fails.

               

              dataproperty

              data:Object  [read-write]

               

               

              The data property lets you pass a value to the component when you use it in an item renderer or item editor. You typically use data binding to bind a field of the data property to a property of this component.

              The ComboBox control uses the listData property and the data property as follows. If the ComboBox is in a DataGrid control, it expects the dataField property of the column to map to a property in the data and sets selectedItem to that property. If the ComboBox control is in a List control, it expects the labelField of the list to map to a property in the data and sets selectedItem to that property. Otherwise, it sets selectedItem to the data itself.

              You do not set this property in MXML.

               

              This property can be used as the source for data binding.

               

               

              Thanks,

              Bhasker