views:

30

answers:

2

Hi

I am using Adobe Air to get data from SalesForce, and present it in a datagrid.

I am using a query to get the data, and then put it into an arraycollection that is bound to the datagrid, this works correctly and the data is displayed.

I have made the datagrid editable, and I am able to change the values in the datagrid, but I cannot find how to save the changes to the local database.

I am using the following code:-

protected function VisitReportGrid_changeHandler(event:ListEvent):void{ app.wrapper.save(VisitReportGridProvider) }

But this has the following error when I try and compile it:-

1067: Implicit coercion of a value of type mx.collections:ArrayCollection to an unrelated type mx.data:IManaged.

Obviously I am doing this wrong, but I cannot find the correct syntax.

Thanks in advance for your help

Roy

+1  A: 

This code is not enough to understand where actually is the problem Need to know what is VisitReportGridProvider, what is wrapper.save() method.

**after comment:

F3DesktopWrapper.save():

          public function save(item:IManaged):void

Saves the specified Managed object to the local database. You must make an explicit call to syncWithServer() to update the data on the salesforce server. However, do not call syncWithServer() too often (batch your save calls) as this may use up your alloted API usage. If the item is in conflict, the conflict will be resolved.

Parameters:

item:IManaged — The managed object to create or update.

you're passing parameter with type ArrayCollection which doesn't implement IManaged interface.

dragonkhan
The VisitReportGridProvider is an Arraycollection that is bound to the datagrid VisitReportGrid, it is created using app.wrapper.query("select Account__c,Start__c,Visit_Report__c from Visitreport__c where Account__c is not null order by Start__c desc", new mx.rpc.Responder(function(data:ArrayCollection):void {VisitReportGridProvider =data;},null)); I thought the wrapper save method was a standard feature, but am not sure, the wrapper is called by private var wrapper:F3DesktopWrapper;.
RoyK
this is a standard features for Toolkit you're using, but not for AirI have not used it at all, maybe this site can help you: http://developer.force.com/flextoolkit
dragonkhan
A: 

You need to pass the item in the ArrayCollection that was changed to the save function. Like:

acc.fieldCollection.updateObject(new AsyncResponder(function(o:Object, t:Object):void {
  app.wrapper.save(o as Account);
}, function(e:Object):void {

}));
James Ward