5 Replies Latest reply on Jan 27, 2011 5:51 PM by Flex harUI

    can't update display list

    Maximist Level 1

      Hallo, i need a little help. I have a list and i need to set the actual selection to null... I think the way is


      this.myList.selectedIndex = -1;




      this.myList.selectedItem = null;


      Right??.. But the display doesn't update cause i still see that element selected. I tried with invalidateDisplayList but it doesn't work.





        • 1. Re: can't update display list
          _spoboyle Level 4

          extension of the adobe list example


          <?xml version="1.0"?>
          <!-- Simple example to demonstrate the Spark List component -->
          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark">
                      import spark.events.IndexChangeEvent;
                      //this function is called when the selection is going to change
                      private function selectionChangingHandler(evt:IndexChangeEvent):void {
                          var item:* = list.dataProvider.getItemAt(evt.newIndex);
                          if (item.type != "employee") {
                      private function resetList():void
                          list.selectedIndex = -1;
              <s:Panel title="Spark List Component Example"
                       width="75%" height="75%"
                       horizontalCenter="0" verticalCenter="0">
                  <s:VGroup left="20" right="20" top="20" bottom="20">
                      <s:Label width="330"
                               text="Select a name to see employee's phone number. You should not be able to select the first name."/>
                      <s:List id="list" changing="selectionChangingHandler(event);">
                          <!-- itemRenderer is inline in this sample -->
                                          <s:State name="normal" />
                                          <s:State name="hovered" />
                                          <s:State name="selected" />
                                      <s:Rect left="0" right="0" top="0" bottom="0">
                                              <s:SolidColor color="0x999999" alpha="0" alpha.hovered="0.2"
                                                            alpha.selected="0.6" />
                                      <s:Label id="nameLabel" text="{data.lastName}, {data.firstName}" top="5" left="5" right="5" />
                                      <s:Label y="20" id="phoneLabel" text="{data.phone}" includeIn="selected" top="25" bottom="5" left="5" right="5" />
                                  <fx:Object type="hr" firstName="Ann"  lastName="Green"  />
                                  <fx:Object type="employee" firstName="Tom"  lastName="Smith" phone="415-155-1212" />
                                  <fx:Object type="employee" firstName="John" lastName="Black" phone="408-344-1234" />
                                  <fx:Object type="employee" firstName="Jane" lastName="White" phone="415-235-7878" />
                                  <fx:Object type="employee" firstName="Bill" lastName="Jones" phone="415-875-7800" />
                      <s:Button label="reset" click="resetList()"/>

          • 2. Re: can't update display list
            Mohit M Chavda Level 1



            As i understand your problem you can not referesh display text that is selected before you give selectedIndex = -1  or selectedItem = null


            I also face this issue after giving selectedItem null internally combobox selectedItem is null at this time it's selectedIndex = -1 but it's label is not be blank .


            For that you used below tric.


            cmd.text = ""; // This is for flex 3
            cmd.textInput.text = ""; // This is for flex 4


            here insted of blank string you can also set some other text like "Select" , "All" as per requirement.


            above syntax you give after setting selectedIndex = -1 or selectedItem = null

            • 3. Re: can't update display list
              Maximist Level 1

              Thank you for the answer but my problem is a little bit different. My item is null but on display it is still selected so my problem i think is the itemRenderer which should go in disabled mode but it doesn't automatically when i set myList.selectedItem = null;


              I don't know how to fix



              • 5. Re: can't update display list
                Flex harUI Adobe Employee

                Can you make a test case in 20 lines or so?  If so, then post it.