Uploaded image for project: 'Apache Flex'
  1. Apache Flex
  2. FLEX-26220

Changing the dataProvider on a ComboBox does not clear the displayed selected item

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Not A Problem
    • Adobe Flex SDK 4.1 (Release)
    • None
    • Spark: ComboBox
    • None
    • Affected OS(s): All OS Platforms
      Affected OS(s): All OS Platforms
      Browser: Firefox 3.x
      Language Found: English

    Description

      Steps to reproduce:
      1. Paste the following code in an application file,

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx">

      <fx:Script>
      <![CDATA[

      protected function button1_clickHandler(event:MouseEvent):void

      { tester.dataProvider = data1; tester.selectedIndex = 0; }

      protected function button2_clickHandler(event:MouseEvent):void

      { tester.dataProvider = data2; tester.selectedIndex = 0; }

      protected function button3_clickHandler(event:MouseEvent):void

      { trace( tester.selectedItem ); }

      ]]
      >
      </fx:Script>

      <fx:Declarations>

      <s:ArrayList id="data1">
      <fx:Object label="data1.1"/>
      <fx:Object label="data1.2"/>
      <fx:Object label="data1.3"/>
      <fx:Object label="data1.4"/>
      <fx:Object label="data1.5"/>
      </s:ArrayList>

      <s:ArrayList id="data2">
      <fx:Object label="data2.1"/>
      <fx:Object label="data2.2"/>
      <fx:Object label="data2.3"/>
      <fx:Object label="data2.4"/>
      <fx:Object label="data2.5"/>
      </s:ArrayList>

      </fx:Declarations>

      <s:layout>
      <s:VerticalLayout/>
      </s:layout>

      <s:ComboBox id="tester"/>

      <s:Button label="data1" click="button1_clickHandler(event)"/>
      <s:Button label="data2" click="button2_clickHandler(event)"/>
      <s:Button label="trace" click="button3_clickHandler(event)"/>

      </s:Application>

      2. Run the application and click on the button labeled 'data1'. This will set the dataProvider on the combobox and set the selectedIndex to 0 (the first item).

      3. Click on the button labeled 'data2'. This will set the dataProvider on the combobox to another set of data and set the selectedIndex to 0 (the first item).

      Actual Results:
      The combobox will show the label for the selectedItem in the first dataProvider. Clicking the button label 'trace' will output that the selectedItem is undefined.

      Expected Results:
      The combobox should show the label for the selectedItem in the second dataProvider. Clicking on the button label 'trace' should output a selectedItem instead of undefined.

      Workaround (if any):
      Set the selectedIndex to -1, then to the required index.

      Attachments

        Activity

          People

            adobejira Adobe JIRA
            adobejira Adobe JIRA
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: