PDA

View Full Version : DataProvider Class


vyellep
04-10-2008, 10:38 PM
Hi,

Is it possible to create a new DataProvider object within a
<mx:Script>
<![CDATA[

private var myDP = new DataProvider();

]]
</mx:Script>

If "yes" where can I import the class definition from? I guess I can do this in AS3 using fl.data but if I need to muck around with a bunch of datagrids and keep assigning their dp with myDP in MXML, is that possible?

Thanks,
-V

vyellep
04-10-2008, 10:48 PM
Never mind. I guess I can always use a recordset for each and make it [Bindable]. That would serve my purpose. Thx

sleekdigital
04-11-2008, 02:21 AM
What do you want to use the Dataprovider for? For Flex components, ArrayCollections and XMLListCollections make the best data providers.

vyellep
04-11-2008, 06:46 AM
I am trying to return recordsets from MySQL via AMFPHP and was hoping to dump them into a DataGrid. Hence I was trying to use a dataprovider/recordset . My goal is to be able to assign the recordset that I receive over AMFPHP directly the datagrid. Am I on the right path?

vyellep
04-11-2008, 08:25 AM
Darn it! I guess the old Recordset class is also not availabe in Flex3. So I will have to do something like this I found on another board

public function getProjects():void

{

amfConnection.call( "Something.getProjects", new
Responder(getProjectsOnResult, OnFault), userInfo.uid);

}



public function getProjectsOnResult( result:Object ) : void

{

var projectDP:ArrayCollection = new ArrayCollection();

for( var i in result.serverInfo.initialData) {

var name:String = result.serverInfo.initialData[i][3];

var pid:String = result.serverInfo.initialData[i][0];

projectDP.addItem({name:name, pid:pid});

}

projects.labelField = "name";

projects.dataProvider = projectDP;

}

sleekdigital
04-11-2008, 02:24 PM
Another option would be to have the server return XML instead of a recordset.

vyellep
04-15-2008, 03:02 AM
Thanks. I went looking for recorset and could not find t. So I just wrote a wrapper to parse my data coming back from AMFPHP to convert into a record set. From now on I have decided to just send back assoc_arrays from AMFPHP. That way I can assign the results directly into my grid