4 Replies Latest reply on May 15, 2009 10:33 PM by Flex harUI

    Datagrid data binding question - associative array

    Bob in SC

      working on my first project and hit another snag.

       

      I have a datagrid control. Here's what works and what doesn't

      - if i have a "normal" array of objects (serverLA) which is used when i create the ArrayCollection (serverAC) -- i.e.

                serverLA[0] = someobject1;

                serverLA[1] = someobject2;

                serverLA[2] = someobject3;

                serverAC=new ArrayCollection(serverLA)

       

           everything seems to work fine.

       

      However, if my array is an associative array where i'm using a string as the key, it doesn't

                serverLA["string1"] = someobject1;

                serverLA["string2"] = someobject2;

                serverLA["string3"] = someobject3;

                serverAC=new ArrayCollection(serverLA)

       

      I don't get any error but nothing appears in the datagrid and when i look at the ArrayCollection object in the debugger...the array elemenets are only under source...none are directly under the ArrayCollection object.

       

      can i use associative arrays for this?

        • 1. Re: Datagrid data binding question - associative array
          Michael Borbor Level 4

          Why don't you use VOs?

           

          Sincerely,

           

          Michael

           

          El 15/05/2009, a las 14:42, Bob in SC <forums@adobe.com> escribió:

           

          >

          working on my first project and hit another snag.

          >

          I have a datagrid control. Here's what works and what doesn't

          - if i have a "normal" array of objects (serverLA) which is used 

          when i create the ArrayCollection (serverAC) -- i.e.

                    serverLA[0] = someobject1;

                    serverLA[1] = someobject2;

                    serverLA[2] = someobject3;

          serverAC=new ArrayCollection(serverLA)

          >

               everything seems to work fine.

          >

          However, if my array is an associative array where i'm using a 

          string as the key, it doesn't

                    serverLA["string1"] = someobject1;

                    serverLA["string2"] = someobject2;

                    serverLA["string3"] = someobject3;

          serverAC=new ArrayCollection(serverLA)

          >

          I don't get any error but nothing appears in the datagrid and when i 

          look at the ArrayCollection object in the debugger...the array 

          elemenets are only under source...none are directly under the 

          ArrayCollection object.

          >

          can i use associative arrays for this?

          >

          • 2. Re: Datagrid data binding question - associative array
            Bob in SC Level 1

            OK...well, what's a VO.

             

            Also, does this mean that it's true that one cannot use an associative array in a data grid control?

            • 3. Re: Datagrid data binding question - associative array
              Michael Borbor Level 4

              I have Never tried using what you want to. A value object is a design

              pattern (class)  that is normally used to transfer data between

              software apps, and represent data.

               

              Did you trace the array collection?

               

              Sincerely,

               

              Michael

              • 4. Re: Datagrid data binding question - associative array
                Flex harUI Adobe Employee

                There are no built-in collections for iterating through an associative array.  If you build one that implements IList then you can use that as the dataProvider for DataGrid.  The key will be defining the order of iteration.  It must be stable regardless of direction.

                 

                Alex Harui

                Flex SDK Developer

                Adobe Systems Inc.

                Blog: http://blogs.adobe.com/aharui