开发者

How do i pass arraycollection to Advancedatagrid using HierarchicalData?

Problem with passing arraycollection to Advance datagrid. My Arraycollection structure like `

 

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}]}

]}

passing AD in dataProvider="{new HierarchicalData(groupList)}" It's working fine. it's show two menu of tree and childrens based on country .But i tried dynamic xml convert to Arraycollection by below code

private function convertXmlToArrayCollection( file:String ):ArrayCollection
   {
    var xml:XMLDocument = new XMLDocument( file );



    //var decoder:SimpleXMLDecoder = new SimpleXMLDecoder();


   var decoder1:SimpleXMLDecoder = new Sim开发者_如何学PythonpleXMLDecoder(true);


    var data1:Object = decoder1.decodeXML( xml );

    var array1:Array = ArrayUtil.toArray(data1);

    return new ArrayCollection( array1 );
   }

my xml structure is

 <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>

So if i tried to convert this format of xml code to arryacollection , it converted the array collection but when will i pass to Advance data grid it not show any result . What did i wrong ?

groupList1= convertXmlToArrayCollection(string1);
Alert.show(groupList1[0].Country[0].Matches[0].id.toString());// output is =701536 

Where did i mistake it ? Plz kindly any one refer me , What will i changed ?


Did you make groupList1 [Bindable]? Also when you set it to the datagrids dataprovider, was it through binding or just simple assignment?

Also have you tried calling 'invalidateDisplayList()' on the datagrid.

Also another option you could try is setting the xml directly as the dataprovider (don't convert to an ArrayCollection).

hope that helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜