5 Replies Latest reply on Feb 16, 2011 3:09 AM by _spoboyle

    Binding is not happening for Datagroup component

    flexiblekrish Level 1

      Hi all,

       

                 I am using arraylist as a dataprovider for the datagroup . for some button click event am updating the values in arraylist , in arraylist values got updated  but its not updating in the UI(Binding problem).

       

      Please help me.

       

      Thanks!!

        • 1. Re: Binding is not happening for Datagroup component
          _spoboyle Level 4

          I have found this recently and it's quite annoying but understandable.

           

          It is becase the arraylist itself hasn't changed only it's contents.

           

          when you add or update an element of the array list if you instead create a new copy of the arraylist do any alterations on this new copy and then assign this new arraylist to the old one you will get the desired behaviour.

           

          There maybe be a better solution but i never got an answer on that.

          1 person found this helpful
          • 2. Re: Binding is not happening for Datagroup component
            flexiblekrish Level 1

            hi

             

                 thank you for gr8 information. i will do that

            • 4. Re: Binding is not happening for Datagroup component
              flexiblekrish Level 1

              Hi,

                     I was using Arryalist then i have changed to Arraycollection , after updation data in the Arraycollection. refreshing the array collection. Now it is binding correctly.

               

              code which is working: (simple code)

               

               

              <?xml version="1.0"?>

              <!-- repeater\RefNestedComponents.mxml -->

              <s:Application

              xmlns:fx="http://ns.adobe.com/mxml/2009"   

              xmlns:mx="library://ns.adobe.com/flex/mx"    

              xmlns:s="library://ns.adobe.com/flex/spark" xmlns:local="*" creationComplete="testd()">

              <fx:Script>

              <![CDATA[

              import mx.collections.ArrayCollection;

              import mx.collections.ArrayList;

              import mx.collections.IList;

               

              [Bindable]

              public var Aarray:ArrayCollection;

               

              public function testd():void{

               

              Aarray = new ArrayCollection([

              {name:"Wilma Carter", Bats:"R", Throws:"R", Year:"So", Home: "Redlands, CA"},

              {name:"Sue Pennypacker", Bats:"L", Throws:"R", Year:"Fr", Home: "Athens, GA"},

              {name:"Jill Smithfield", Bats:"R", Throws:"L", Year:"Sr", Home: "Spokane, WA"},

              {name:"Shirley Goth", Bats:"R", Throws:"R", Year:"Sr", Home: "Carson, NV"},

              {name:"Jennifer Dunbar", Bats:"R", Throws:"R", Year:"Fr", Home: "Seaside, CA"},

              ]);

               

              }

               

              public function change(e:Event):void{

              Aarray[1].name ="tested";

              Aarray.refresh();

               

              }

              ]]>

              </fx:Script>

               

              <s:layout>

              <s:VerticalLayout/>

              </s:layout>

               

              <s:DataGroup id="datagroup" dataProvider="{Aarray}" >

              <s:layout>

              <s:VerticalLayout/>

              </s:layout>

              <s:itemRenderer>

              <fx:Component >

              <mx:Text text="{data.name}"/>

              </fx:Component>

              </s:itemRenderer>

               

              </s:DataGroup>

               

              <s:Button  click="change(event)" label="click to change"/>

              </s:Application>

              • 5. Re: Binding is not happening for Datagroup component
                _spoboyle Level 4

                great you found a better way of solving the problem however for me that solution doesn't work, odd