我有一个 ArrayCollection 填充了 'o' 对象。这个 AC 应该是 DataGrid 的 dataProvider。设置dp后:dgMT.dataProvider=acDataGrid
DataGrid只包含arrayCollection的最后一项。代码:
[Bindable]
public var acDataGrid:ArrayCollection = new ArrayCollection();
protected function ddlLanguage_changeHandler(event:IndexChangeEvent):void{
gcTranslate.headerText=Globals.acLanguages.getItemAt(ddlLanguage.selectedIndex,0).toString();
Globals.acActValues=convertXmlToArrayCollection(File.applicationDirectory.resolvePath("xmls"+File.separator+Globals.acFileNames.getItemAt(ddlLanguage.selectedIndex,0)));
Globals.acDataGrid.removeAll();
var o:DataGridObject = new DataGridObject();
var i:int=0;
var angol:Object;
for each(angol in Globals.acValues){
o.en=angol.value;
o.name=angol.name;
if(i<Globals.acActValues.length && o.name==Globals.acActValues.getItemAt(i,0).name){
o.translation=Globals.acActValues.getItemAt(i,0).value;
}
else{
o.translation="";
Globals.acActValues.addItemAt("",i);
}
acDataGrid.addItemAt(o,i);
trace("NAME: "+acDataGrid.getItemAt(i,0).name+" VAL:"+acDataGrid.getItemAt(i,0).en+"TRANS: "+acDataGrid.getItemAt(i,0).translation);
// the values are different!
i++;
}
dgMT.dataProvider=acDataGrid;//setting the dataProvider
}
我怎样才能达到 DataGrid 的行填充了正确的值?谢谢!