3 Replies Latest reply on Aug 18, 2010 4:37 AM by Vikash.kumar29

    Issue in Combobox flex 3.5

    Vikash.kumar29 Level 3

      Hello all,

       

      I got a serious issue in combobox while using flex sdk 3.5.

      The issue is if we filter the collection before creation complete of component and use that filtered collection as a dataprovider for combobox.

      If the result from the filtered collection is a blank collection then that combobox is still pouplated from the first value from the source of collection. However the actual result should be null in the selected item of comboBox.

       

      Giving you the sample test code to reproduce the issue.

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*" 
           initialize="onInitialize()"     >
           <mx:Script>
                <![CDATA[
                     import mx.collections.ArrayCollection;
                     [Bindable]
                     private var dp:ArrayCollection = new ArrayCollection(['t1','t2','t3']);
                     
                     private function filterFunction(inData:Object):Boolean
                     {
                          return false;
                     }
                     
                     private function onInitialize():void
                     {
                          dp.filterFunction=filterFunction;
                          dp.refresh()
                     }
                     
                ]]>
           </mx:Script>
           <mx:ComboBox id="cb" dataProvider="{dp}" x="66" y="31"/>
           <mx:Button  label="Refresh DP"  x="102" y="92" click="dp.refresh()"/>
      </mx:Application>
      

       

      However it is corrected after refreshing the dataprovider after creation complete. But I don't want to refresh it everywhere thoughout my application.

       

      Please, provide your comments on this.

       

      Thanks

      Vikash Kumar

        • 1. Re: Issue in Combobox flex 3.5
          mung_2

          You actually want to filter the arrayCollection on creationComplete, not initialize, so replace

           

           

          initialize="onInitialize()"

           

          to

           

          creationComplete="onInitialize()"
          • 2. Re: Issue in Combobox flex 3.5
            BhaskerChari Level 4

            Hi Vikash Kumar,

             

             

            Just put the initialize event on ComboBox itself instead of Application tag....as shown below...

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" xmlns:local="*"
                      >
                 <mx:Script>
                      <![CDATA[
                           import mx.collections.ArrayCollection;
                           [Bindable]
                           private var dp:ArrayCollection = new ArrayCollection(['t1','t2','t3']);
                          
                           private function filterFunction(inData:Object):Boolean
                           {
                                return false;
                           }
                          
                           private function onInitialize():void
                           {
                                dp.filterFunction=filterFunction;
                                dp.refresh()
                           }
                          
                      ]]>
                 </mx:Script>
                 <mx:ComboBox id="cb" dataProvider="{dp}" x="66" y="31" initialize="onInitialize()"/>
                 <mx:Button  label="Refresh DP"  x="102" y="92" click="dp.refresh()"/>
            </mx:Application>

             

             

            Thanks,

            Bhasker

            • 3. Re: Issue in Combobox flex 3.5
              Vikash.kumar29 Level 3

              Thanks your reply,

               

              I appreciate your support,but however this does not suits me as I am using datamodel for the real time application and its complete its background processing before the creationcomplete of the component and filters the collection and hence leads to the bug reproduced by the sample application.