In flex 2, it's unbelievably easy... you just bind the arrayCollection right to the grid.
 
<mx:DataGrid dataProvider="{fcAll}" x="51" y="98" width="562.5" height="253" id="reportGrid">
 
Or, if you need to do it in AS instead:
reportGrid.dataProvider = fcAll;
 
Shan


From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Ben Agre
Sent: Tuesday, July 11, 2006 9:56 AM
To: [email protected]
Subject: [Junk E-Mail - LOW] [flexcoders] need help using an array or array collection as a dataprovider for a datagrid

Basically i want to use an array preferably an array collection to be
a dataprovider for a grid. I know before flex 2 you use to be able to
use dataprovider.additem, however now I cannot seem to do that.
What i have now that currently shows just blank for it is :

var fcAll:ArrayCollection=new ArrayCollection();
var fcName_:Array = new Array();
var fcDate_:Array = new Array();
var fcCount_:Array = new Array();
fcAll = httpFC_Report.lastResult.sql_results.result_set.rows.row;

var fcNameOut_:Array = new Array();
var fcDateOut_:Array = new Array();
var fcCountOut_:Array = new Array();

for (var i:int=0; i<fcAll.length; i++) {
var seq:int = 0;

fcDate_[i] = fcAll[i].value1.toString();// col_name
fcName_[i] = fcAll[i].value2.toString();// fld_name
fcCount_[i] = fcAll[i].value3.toString();// col_type
fcDateOut_[i] = fcDate_[i];// col_name
fcCountOut_[i]= fcCount_[i];
fcNameOut_[i]=fcAll[i].value2.toString();
}

for(i=0; n< fcName_.length; n++){
grid.dataProvider ({name:fcName_[n], date:fcDate_[n], count:fcCount_[n]});
}

and my xml for the datagrid is

<mx:DataGrid x="51" y="98" width="562.5" height="253" id="reportGrid">
<!--
dataProvider="{httpFC_Report.lastResult.sql_results.result_set.rows.row}"
-->
<mx:columns>
<mx:DataGridColumn headerText="Filecabinet Name" width="250"
dataField="name"/>
<mx:DataGridColumn headerText="Date" width="100" dataField="date"/>
<mx:DataGridColumn headerText="Count" dataField="count"/>
</mx:columns>
</mx:DataGrid>

Any help you could provide would be greatly appreciated, tia
Also something like what i want to do is here
http://groups.yahoo.com/group/flexcoders/message/42568
Sincerely,
Ben


--
No virus found in this incoming message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/384 - Release Date: 7/10/2006

__._,_.___

--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com





YAHOO! GROUPS LINKS




__,_._,___

--
No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.1.394 / Virus Database: 268.9.10/384 - Release Date: 7/10/2006

Reply via email to