将数组集合传递到Advance数据网格时出现问题。我的数组集合结构类似于'
private var groupList:ArrayCollection = new ArrayCollection([
{Country:'India', children:[
{Country:'Series1', children:[
{Matches:'India Test series 1',isEnable:false,id:1,isSelected:true},
{Matches:'India Test series 2',isEnable:false,id:2,isSelected:true},
{Matches:'India Test series 3',isEnable:false,id:3,isSelected:true}]},
{Country:'Series2', children:[
{Matches:'Australia Test series 1',isEnable:false,id:25,isSelected:true},
{Matches:'Australia Test series 2',isEnable:false,id:26,isSelected:true},
{Matches:'Australia Test series 3',isEnable:false,id:27,isSelected:true}]}
]},
{Country:'Austrila', children:[
{Country:'Series1', children:[
{Matches:'Australia Test series 1',isEnable:false,id:46,isSelected:true},
{Matches:'Australia Test series 2',isEnable:false,id:47,isSelected:true},
{Matches:'Australia Test series 3',isEnable:false,id:48,isSelected:true}]},
{Country:'Series2', children:[
{Matches:'Australia Test series 1',isEnable:false,id:49,isSelected:true},
{Matches:'Australia Test series 2',isEnable:false,id:50,isSelected:true},
{Matches:'Australia Test series 3',isEnable:false,id:51,isSelected:true}]},
{Country:'Series3', children:[
{Matches:'Australia Test series 1',isEnable:false,id:52,isSelected:true},
{Matches:'Australia Test series 2',isEnable:false,id:53,isSelected:true},
{Matches:'Australia Test series 3',isEnable:false,id:54,isSelected:true}]}
]}
在dataProvider="{new HierarchicalData(groupList)}"
中传递AD,运行良好。它显示了基于国家的树和子菜单。但我尝试通过以下代码将动态xml转换为Arraycollection
private function convertXmlToArrayCollection( file:String ):ArrayCollection
{
var xml:XMLDocument = new XMLDocument( file );
//var decoder:SimpleXMLDecoder = new SimpleXMLDecoder();
var decoder1:SimpleXMLDecoder = new SimpleXMLDecoder(true);
var data1:Object = decoder1.decodeXML( xml );
var array1:Array = ArrayUtil.toArray(data1);
return new ArrayCollection( array1 );
}
我的XML结构是
<Country Country="India ">
<Country Country="Series ">
<Matches Matches="BIndependiente-Colon" id="701536" isEnable="false" isSelected="true" startDate="2009-10-29 01:30:00" EndDate="2009-10-29 01:30:00"/>
<Matches Matches="Boca Juniors-Chacarita Juniors" id="701633" isEnable="false" isSelected="true" startDate="2009-10-29 19:00:00" EndDate=""/>
</Country>
</Country>
<Country Country="Australia">
<Country Country="series">
<Matches Matches="BIndependiente-Colon" id="701536" isEnable="false" isSelected="true" startDate="2009-10-29 01:30:00" EndDate="2009-10-29 01:30:00"/>
<Matches Matches="Boca Juniors-Chacarita Juniors" id="701633" isEnable="false" isSelected="true" startDate="2009-10-29 19:00:00" EndDate=""/>
</Country>
</Country>
因此,如果我试图将这种格式的xml代码转换为arryacollection,它转换了数组集合,但当我传递到高级数据网格时,它不会显示任何结果。我错了什么?
groupList1= convertXmlToArrayCollection(string1);
Alert.show(groupList1[0].Country[0].Matches[0].id.toString());// output is =701536
我哪里弄错了?请告诉我,我会改什么?
1条答案
按热度按时间h6my8fg21#
您是否将groupList1设置为[Bindable]?另外,当您将其设置为datagrid数据提供程序时,是通过绑定还是仅通过简单的赋值?
您是否也尝试过在数据网格上调用
'invalidateDisplayList()'
。您还可以尝试另一个选项,即直接将xml设置为数据提供者(不转换为ArrayCollection)。
希望这能有所帮助