|
You can’t really use an associative
array as a dataProvider. You’ll need to create a real array andthen
create the two fields as appropriate. If you’re passed the associative
array and can’t just change what you have, you could do this: goData = new Object();
var oData:Object;
for ( var i:Number=0; i<5; i++ ) {
oData = new
Object({name:"Name of item " + i})
goData["key"
+ i] = oData;
}//for ( var i:Number=0;.... var dp : Array = new Array; for (var key in goData) { dp.push({key: key, value: goData[key]}); } Then column 1 is key and column 2 is
value. Matt From: Tracy Spratt
[mailto:[EMAIL PROTECTED] I
have an associative array in a variable created like so:
goData = new Object();
var oData:Object;
for ( var i:Number=0; i<5; i++ ) {
oData = new
Object({name:"Name of item " + i})
goData["key"
+ i] = oData;
}//for ( var i:Number=0;.... I
can iterate through it and see the data fine. But
how do I reference it in the dataProvider property to get an item for each
element? Using toArray() results in a single item with 5 properties.
(I can see them in the FB debugger with a breakpoint on the label function)
Without toArray the labelFunction item is undefined. And
if I get that, how do I return the key value in the label
function? My
goal is a 2 column DataGrid with the key/propertyname
in one column and the dataObject.name value in the second.
|
Title: Associative array as dataProvider

