4 Replies Latest reply on Aug 28, 2008 12:32 PM by Newsgroup_User

    DataGrid -- Loop?  All rows

    Vesta0424
      This should be simple, but I am new to Flex and cannot find a specific code example for this.

      I have a DataGrid that is populated via actionscript from the contents a user selects from a ComboBox and a DateField. So there are repeating rows of ComboBox Value, Date Value displayed in the DataGrid.

      When the data is submitted I have to build a DTO of the values of the Data so that they passed to a service for data entry into an Oracle Table (each table row corresponding to a row of the DataGrid)

      All the examples I have seen get the DataGrid values by looping the dataprovider -- which is no help, because this DataGrid is not populated by a dataprovider.

      I also see a lot of references to accessing the selectedItem of a DataGrid, but in this case, there are no selected items. I need to get all the items and bundle them up in a collection of objects.

      I hope I am being clear here. Code examples would be very helpful. If no examples a pointer in the general direction would be appreciated.

      Thanks in advance for your help.

      Georgia
        • 1. Re: DataGrid -- Loop?  All rows
          Gregory Lafrance Level 6
          I still believe you should be working with a dataProvider, in this case probably an ArrayCollection of objects.

          Instead of populating the DataGrid via AS as you say is currently the case, populate the dataProvider via AS, then that ArrayCollection will be readily available to build your DTO.

          As you implement this you may find another layer of complexity, but I think it makes sense to try to keep to Flex basics, and don't let the temptation to be too creative lead you away from the beauty of simplicity.
          • 2. Re: DataGrid -- Loop?  All rows
            Level 7

            "Vesta0424" <webforumsuser@macromedia.com> wrote in message
            news:g96guo$3s0$1@forums.macromedia.com...
            > This should be simple, but I am new to Flex and cannot find a specific
            > code
            > example for this.
            >
            > I have a DataGrid that is populated via actionscript from the contents a
            > user
            > selects from a ComboBox and a DateField. So there are repeating rows of
            > ComboBox Value, Date Value displayed in the DataGrid.
            >
            > When the data is submitted I have to build a DTO of the values of the Data
            > so
            > that they passed to a service for data entry into an Oracle Table (each
            > table
            > row corresponding to a row of the DataGrid)
            >
            > All the examples I have seen get the DataGrid values by looping the
            > dataprovider -- which is no help, because this DataGrid is not populated
            > by a
            > dataprovider.
            >
            > I also see a lot of references to accessing the selectedItem of a
            > DataGrid,
            > but in this case, there are no selected items. I need to get all the
            > items
            > and bundle them up in a collection of objects.
            >
            > I hope I am being clear here. Code examples would be very helpful. If no
            > examples a pointer in the general direction would be appreciated.

            If the DataGrid is showing anything at all, it has a dataProvider.

            HTH;

            Amy


            • 3. Re: DataGrid -- Loop?  All rows
              Vesta0424 Level 1
              Thanks for the replies. Actually, there IS a dataprovider built in the ActionScript. Sorry. The dataprovider is actually set on the instantiation of a DataGrid component .... which I didn't even know you could do!

              I think that Flex is making me stupid.
              • 4. Re: DataGrid -- Loop?  All rows
                Level 7

                "Vesta0424" <webforumsuser@macromedia.com> wrote in message
                news:g96ro1$f8c$1@forums.macromedia.com...
                > Thanks for the replies. Actually, there IS a dataprovider built in the
                > ActionScript. Sorry. The dataprovider is actually set on the
                > instantiation
                > of a DataGrid component .... which I didn't even know you could do!
                >
                > I think that Flex is making me stupid.

                It has that effect on me, too ;-)