[flexcoders] Re: Refreshing Datagrid from pop up window

2007-02-11 Thread munene_uk
ive checked the contents returned and they are exactly the same as the
data that populates the grid when the application loads however the only
difference between the two is that the first call to update the grid on
application load has this line


dataProvider = new ArrayCollection ( ArrayUtil.toArray(evt.result) ); //
same as: evt.result.toString();

  please  look at the code below the first function populates the
datagrid on the first run

while the second function returns the results of the added item.

  private function resultHandler(evt:ResultEvent):void
 {
 dataProvider = new ArrayCollection (
ArrayUtil.toArray(evt.result) ); // same as:evt.result.toString();
 }


public function sendResultHandler(evt:ResultEvent):void
 {

dataProvider.addItem(ArrayUtil.toArray(evt.result));
dataProvider.refresh();
 }



the thing is if i change the second function to:

public function sendResultHandler(evt:ResultEvent):void
 {
   dataProvider = new ArrayCollection (
ArrayUtil.toArray(evt.result) );
dataProvider.addItem(ArrayUtil.toArray(evt.result));
dataProvider.refresh();
 }

it actually populates the datagrid with the last added item however in
the process(as i said earlier) it also wipes everything off the array
collection becuase of the first line in that function.
what i dont understand is the blank row that appears...sorry if my
explenation is a bit confusing im still new to this as wel








Re: [flexcoders] Re: Refreshing Datagrid from pop up window

2007-02-10 Thread Adam Royle
That's certainly interesting. I would try and debug the result of:

ArrayUtil.toArray(evt.result));

To make sure the data is the correct type, and columns named correctly. Just a 
stab in the dark. I know the technique does work as I use it in my app - but 
you might just need to check your return values and make sure they are what you 
expect.

Cheers,
Adam


  - Original Message - 
  From: munene_uk 
  To: flexcoders@yahoogroups.com 
  Sent: Sunday, February 11, 2007 4:44 AM
  Subject: [flexcoders] Re: Refreshing Datagrid from pop up window



  well im back with another problem...

  i followed your example

   private function sendResultHandler(evt:ResultEvent):void
  {
dataProvider.addItem(ArrayUtil.toArray(evt.result));
 dataProvider.refresh();
   
  }

  however all it does is add a blank result to the datagrid but once i refresh 
using the browser the  newly updated row appears

  interstingly i tried this:

   private function sendResultHandler(evt:ResultEvent):void
  {
   dataProvider = new ArrayCollection ( ArrayUtil.toArray(evt.result) );
   dataProvider.addItem(ArrayUtil.toArray(evt.result));
   dataProvider.refresh();
   
  }

  obviously this completely wipes the data currently displayed on the datagrid 
but this acutally displays the newly updated item.

  this is how i've declared my data provider

  [Bindable]
  public var dataProvider:ArrayCollection = new ArrayCollection();



  any ideas? anyone?




   

[flexcoders] Re: Refreshing Datagrid from pop up window

2007-02-10 Thread munene_uk

well im back with another problem...

i followed your example

  private function sendResultHandler(evt:ResultEvent):void
 {
   dataProvider.addItem(ArrayUtil.toArray(evt.result));
dataProvider.refresh();

 }

however all it does is add a blank result to the datagrid but once i
refresh using the browser the  newly updated row appears

interstingly i tried this:

  private function sendResultHandler(evt:ResultEvent):void
{
  dataProvider = new ArrayCollection ( ArrayUtil.toArray(evt.result) );
  dataProvider.addItem(ArrayUtil.toArray(evt.result));
  dataProvider.refresh();

}

obviously this completely wipes the data currently displayed on the
datagrid but this acutally displays the newly updated item.

this is how i've declared my data provider

[Bindable]
public var dataProvider:ArrayCollection = new ArrayCollection();



any ideas? anyone?





Re: [flexcoders] Re: Refreshing Datagrid from pop up window

2007-02-05 Thread Adam Royle
I'm a beginner myself as well, so I don't really know - maybe someone else can 
elaborate. I liked it simply because it is quite fast and easy to use, and I 
guess it must have been one of the first samples I looked at. :)

Adam


  - Original Message - 
  From: munene_uk 
  To: flexcoders@yahoogroups.com 
  Sent: Tuesday, February 06, 2007 4:49 AM
  Subject: [flexcoders] Re: Refreshing Datagrid from pop up window


  what can i say..thank you so much that has really helped understand 
  what im doing...could i ask what is the advantage of using remoting 
  connection over remote object...the reason im asking is because i was 
  using remoting connection before.



   

[flexcoders] Re: Refreshing Datagrid from pop up window

2007-02-05 Thread munene_uk
what can i say..thank you so much that has really helped understand 
what im doing...could i ask what is the advantage of using remoting 
connection over remote object...the reason im asking is because i was 
using remoting connection before.



Re: [flexcoders] Re: Refreshing Datagrid from pop up window

2007-02-05 Thread Adam Royle
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: flexcoders@yahoogroups.com 
  Sent: Monday, February 05, 2007 11:18 PM
  Subject: [flexcoders] Re: Refreshing Datagrid from pop up window


  --- In flexcoders@yahoogroups.com, "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: flexcoders@yahoogroups.com 
  > 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.



   

[flexcoders] Re: Refreshing Datagrid from pop up window

2007-02-05 Thread munene_uk
--- In flexcoders@yahoogroups.com, "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: flexcoders@yahoogroups.com 
>   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.