8 Replies Latest reply on Sep 5, 2007 7:44 AM by GeorgeWS

    Edit datagrid then send to DB

    GeorgeWS Level 1
      I have been at this for a week. I fill a datagrid with an arrayCollection (myAccounts). This arrayCollection is populated from a RemoteObject. I want to edit one column (true, false) modifying a few rows. Then press submit and have the data get inserted into a table. I am baffled... Im sure I will need a sample

      Thanks
      George
        • 1. Re: Edit datagrid then send to DB
          Level 7
          http://flexapps.macromedia.com/flex2beta3/explorer/explorer.html
          Take a look at datagrid add, update sample, that will help you to start.
          Rgds

          JFB

          "GeorgeWS" <webforumsuser@macromedia.com> wrote in message
          news:f9fhae$a70$1@forums.macromedia.com...
          >I have been at this for a week. I fill a datagrid with an arrayCollection
          > (myAccounts). This arrayCollection is populated from a RemoteObject. I
          > want to
          > edit one column (true, false) modifying a few rows. Then press submit and
          > have
          > the data get inserted into a table. I am baffled... Im sure I will need a
          > sample
          >
          > Thanks
          > George
          >


          • 2. Re: Edit datagrid then send to DB
            GeorgeWS Level 1
            Thanks but that only updates one record at a time. So its not very close to what I want. I would think that editing a grid and sending the edited array back would be fairly easy if not super colmon. I have been searching all over (2 weeks) for answers but they all leat to a dead end with omeone saying "oh yeah thats easy just loop over the arraycollection and send it to the CFC." I need to see how. Can anyone provide a sample?

            Datagrid filled with data from a arraycollection that comes from a RO call to a CFC.
            Edit some rows in a column and press SEND button.
            A table gets the records INSERTED into a table. 5 rows edited = 5 rows in the table.

            Thanks
            George
            • 3. Re: Edit datagrid then send to DB
              Level 7
              Well, I post also a question here two weeks ago without answer, I think we
              need to send a message to Adobe so they can try to put more people in these
              news group to help more people. Microsoft does a better work in these matter
              :)
              Here I give you an example about how to use CFC's with Flex.
              http://www.kylehayes.info/captivate/QueryToDatagrid/QueryToDataGrid.htm
              Datagrid is a tool to display data, in the example that I send you before
              give you the idea to add and update the array.
              I give you and idea how to do the update.
              Close to your datagrid create two buttons, one for ADD and another for
              UPDATE and when you click the button fire a function.
              Inside tha function fire the method that you need, make sure you have all
              the parameters defined passing the right data.

              <mx:RemoteObject id="my_RO" destination="ColdFusion" source="sample">
              <mx:method name="updateContact" result="getContactRO_Handler(event)">
              <mx:arguments>
              <contactID>3232</contactID>
              <contactName>3232</contactName>
              <contactLastName>3232</contactLastName>
              </mx:arguments>
              </mx:method>
              </mx:RemoteObject>
              The rest you can get from the example
              Good luck
              Rgds

              JFB


              "GeorgeWS" <webforumsuser@macromedia.com> wrote in message
              news:f9sqh4$fa$1@forums.macromedia.com...
              > Thanks but that only updates one record at a time. So its not very close
              > to
              > what I want. I would think that editing a grid and sending the edited
              > array
              > back would be fairly easy if not super colmon. I have been searching all
              > over
              > (2 weeks) for answers but they all leat to a dead end with omeone saying
              > "oh
              > yeah thats easy just loop over the arraycollection and send it to the
              > CFC." I
              > need to see how. Can anyone provide a sample?
              >
              > Datagrid filled with data from a arraycollection that comes from a RO call
              > to
              > a CFC.
              > Edit some rows in a column and press SEND button.
              > A table gets the records INSERTED into a table. 5 rows edited = 5 rows in
              > the
              > table.
              >
              > Thanks
              > George
              >
              >


              • 4. Re: Edit datagrid then send to DB
                GeorgeWS Level 1
                Can you believe it, more than a month posting and posting and reading and searching and its looking like know one REALLY knows how to do this request. Im only replying to see if anyone has gained this knowledge over the past month.

                Thanks
                • 5. Re: Edit datagrid then send to DB
                  cmarkiewicz
                  Hello. Not sure if this answers your question. In my current project, I call a web service for data and populate an ArrayList - and populate a DataGrid with the ArrayList. When someone modifies the data and hits the update button, I have a handler which grabs the data from the ArrayList, so i grab each record that was modified, and build the update statement. (Each item in the ArrayList will have the unique id for the row, as well as all data that is displayed in the data grid.)
                  Hope this helps.
                  chris
                  • 6. Re: Edit datagrid then send to DB
                    GeorgeWS Level 1
                    Yes, this is like what I want to do. What does the send part that the update button looks like? And what does the CFC insert look like? Im using an arrayCollection but it should be similar.

                    Thanks

                    George
                    • 7. Re: Edit datagrid then send to DB
                      cmarkiewicz Level 1
                      Hello. My mistake - ArrayCollection. Well, my update method has access to the ArrayCollection object. So I keep track of which records have been modified. Suppose the first record in the DG was modified. I grab that item from the ArrayCollection, grab the Id and appropriate values from that item, build my object, and pass it back to the data source. Presumably with a database it would be the same thing. You'd either build the sql statement - or the object if you're working with a persistence layer abstraction library...then tell it to update the db.
                      chris
                      • 8. Re: Edit datagrid then send to DB
                        GeorgeWS Level 1
                        Chris,
                        Thanks for the concept, I actually know all that you have said. I just cant do it without the syntax. What does the send RemoteObject look like? What does the INSERT part of the CFC look like? Are there any samples of this?

                        George