3 Replies Latest reply on Feb 16, 2007 8:23 AM by michael_ramirez44

    Datagrid row update

      Is there a way using the Datagrid to tell if a row has been updated? Here's an example: Let's say I have 100 rows of data in my grid.. I make a change to 1 row, I click my SUBMIT button, package up the data into an array and send it to my CFC. I'm wondering if I can just package up that 1 row I edited and send it to my CFC... How do I determine if that row has been edited??? Is there an easy way? Cause I'm looking at sending all the data to the CFC. Doing a delete in the DB and then re-adding all the data from my grid... The problem is that there is room for big error here.... ANy suggestions?
        • 1. Re: Datagrid row update
          rotoole Level 1
          you could do doubleClick() function in the datagrid to Update the row in the db but that would be a row by row process and get pretty redundant if you had to modify a large number of rows.

          you could also call a function with the change() function in the datagrid to populate an array with the rows primary key (id or whatever) and then on submit call the array so it knows which rows to Update. getting the info of the right rows might be more difficult than it sounds but maybe if you use the selectedIndex as well or something to that effect.
          • 2. Re: Datagrid row update
            187_2007 Level 1
            hummmm... This my be my solution here.... Thanks
            • 3. Re: Datagrid row update
              michael_ramirez44 Level 1
              I am writing a Amfphp tutorial that does what you want to do using a AsyncToken.

              empRO is my RemoteObject.
              emp is my Employee object I will be saving.
              dp is my dataprovider which is an ArrayCollection of Employee objects.
              The empRO.save method returns an Employee object

              var token:Object = new Object();
              token = empRO.save.send(emp);
              token.index = dp.getItemIndex(emp);

              private function saveHandler(event:ResultEvent):void

              index = Number(event.token.index);

              if( index > -1 )
              //Replace updated Employee
              //Append new Employee


              Do the same with the deleting an object. Here is the removeHandler

              private function removeHandler(event:ResultEvent):void

              index = Number(event.token.index);

              if( index > -1 )
              //Remove Employee is it exists in dataProvider


              This solution is not without its problems. If you sort the datagrid between RemoteObject calls you will edit/delete the wrong object. Here is a link to the example application my tutorial uses.