OK, so this is similar to what I have, however I think you might be using the 
RemoteObject component, while I'm using the RemotingConnection class. This is 
how it would work using RemotingConnection.


public var dataProvider:ArrayCollection = new ArrayCollection();

public function onAddStudent(result:Array):void
{
 if (!result) return;
 dataProvider.addItem(result);
 dataProvider.refresh();
}


You can see it's quite simple. The dataProvider ArrayCollection can be (should 
be) bound to a datagrid. 

If you are using something similar to this 
(http://www.sephiroth.it/tutorials/flashPHP/flex_remoteobject/page004.php) then 
your code might look like this:



public var dataProvider:ArrayCollection = new ArrayCollection();

public function onAddStudent(evt:ResultEvent):void
{
 if (!evt.result) return;
 dataProvider.addItem(ArrayUtil.toArray(evt.result));
 dataProvider.refresh();
}



With my PHP script, what I actually do is:
- validate/format data
- insert into database
- select inserted rows from database
- format data
- return data to flex

Hope this helps
Adam

  ----- Original Message ----- 
  From: munene_uk 
  To: [email protected] 
  Sent: Monday, February 05, 2007 11:18 PM
  Subject: [flexcoders] Re: Refreshing Datagrid from pop up window


  --- In [email protected], "Adam Royle" <[EMAIL PROTECTED]> wrote:
  >
  > Not sure whether you want actionscript, or just a "how to", but I 
  have done it in my app like this.
  > 
  > On update I send the data much like you have, and get the same data 
  returned from amfphp. Then I just do an .addItem() call with the new 
  data on the ArrayCollection that is binded to my datagrid, and then 
  a .refresh() on my dataprovider. 
  > 
  > Doing it this way has its benefits:
  > 
  > - only partial updates, so don't have to get all data back.
  > - inserting return data (instead of directly from form) means you 
  can have some validation and formatting on the server
  > 
  > But it also has it's downfalls:
  > 
  > - will not get new (or remove deleted) data that was updated 
  outside of the current flex app
  > 
  > Hope this helps. 
  > 
  > Cheers,
  > Adam
  > 
  > ----- Original Message ----- 
  > From: munene_uk 
  > To: [email protected] 
  > Sent: Monday, February 05, 2007 3:14 AM
  > Subject: [flexcoders] Refreshing Datagrid from pop up window
  > 
  > 
  > I have a datagrid that retrieves user detials from a database 
  using AMFPHP 1.9. Within the same application, i also have an option 
  for adding new users to the database via a custom pop window form. 
  How can i get the datagrid to automatically update once i have sent 
  the new users details to the database. I'm not using FDS because im 
  not too sure whether its needed for such a task.
  > 
  > 
  > this is the code that sends the user details once you click "save"
  > 
  > private function addStudent(details:Array):void
  > {
  > 
  > myservice.getOperation('addStudent').send(details);
  > PopUpManager.removePopUp(this);
  > }
  > 
  > I would i deally like to also make a call to the main 
  application in order to refresh the datagrid.
  > 
  > 
  > So in short... how can i update the datagrid in my main 
  application automatically from the pop up window?
  >

  Thanks Adam this is pretty much what i want to do...is there any 
  chance you could show me an example from your code where the methods 
  addItem() and refresh() are called. I assume your using amfphp 1.9.

  is the data being retrieved from php or are you just relaying the 
  data that wa input in flex. this is important for me to know because 
  my php includes some validation on server side.



   

Reply via email to