2 Replies Latest reply on Jun 15, 2011 9:43 AM by Flex harUI

    ComboBox retaining initial values with Flex 3.5 SDK :(

    NitinPunjwani

      Hello All,

       

      Please run the following code using Flex SDK 3.5 and see the output. Selection of any department name in first Combo box  should display related sub-department names in the second combo box. However, while running this example with Flex SDK 3.5, the second combo box (meant for displaying sub department values)  displays only the first related subdepartment value correctly while retaining the rest of its values with that of the initial selection of the first combo box.

       

      ========================================================================================== ====================

       

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" minWidth="955" minHeight="600">
          <mx:Script>
              <![CDATA[
                 
                  [Bindable]
                  public var departmentsXML:XML = <Departments>
                                              <Department>
                                                  <ID>1</ID>
                                                  <Name>A</Name>
                                                      <SubDepartments>
                                                          <SubDepartment>
                                                              <ID>1</ID>
                                                              <Name>P</Name>
                                                          </SubDepartment>
                                                          <SubDepartment>
                                                              <ID>2</ID>
                                                              <Name>Q</Name>
                                                          </SubDepartment>
                                                       </SubDepartments>
                                              </Department>
                                              <Department>
                                                  <ID>2</ID>
                                                  <Name>B</Name>
                                                      <SubDepartments>
                                                          <SubDepartment>
                                                              <ID>3</ID>
                                                              <Name>R</Name>
                                                          </SubDepartment>
                                                          <SubDepartment>
                                                              <ID>4</ID>
                                                              <Name>S</Name>
                                                          </SubDepartment>
                                                       </SubDepartments>
                                              </Department>
                                              <Department>
                                                  <ID>3</ID>
                                                  <Name>C</Name>
                                                      <SubDepartments>
                                                          <SubDepartment>
                                                              <ID>5</ID>
                                                              <Name>Y</Name>
                                                          </SubDepartment>
                                                          <SubDepartment>
                                                              <ID>6</ID>
                                                              <Name>Z</Name>
                                                          </SubDepartment>
                                                       </SubDepartments>
                                              </Department>
                                          </Departments>;
                 
                 
                 
                 
                 
                  [Bindable]
                  public var subDepartmentsXML:XML;
                 
                  private function updateDepartment(event:Event):void {
                      var departmentFilterId:String = departmentComboObj.selectedItem.ID;
                     
                      populateCorrespondingSubDepartments(departmentFilterId);
                  }
                 
                  private function populateCorrespondingSubDepartments(departmentID:String):void {
                     
                      var correspondingSubDepartments:XMLList = this.departmentsXML.Department.(ID==departmentID).SubDepartments;
                      this.subDepartmentsXML = XML(correspondingSubDepartments.toXMLString());
                     
                     
                     
                  }
                 
              ]]>
          </mx:Script>
         
         
          <mx:VBox width="30%" x="203" y="100">
             
              <mx:ComboBox itemRenderer="mx.controls.Label" width="100%" id="departmentComboObj" labelField="Name" dataProvider="{this.departmentsXML.Department}"
                           change="updateDepartment(event)"/>
              <mx:ComboBox width="100%" id="subDepartmentComboObj" labelField="Name" itemRenderer="mx.controls.Label" dataProvider="{this.subDepartmentsXML.SubDepartment}"/>
          </mx:VBox>

       

      </mx:Application>

       

      ========================================================================================== ======================

       

      Awaiting for pormpt and assertive response.