How do i pass arraycollection to Advancedatagrid using HierarchicalData ?

Posted by R.Vijayakumar on Stack Overflow See other posts from Stack Overflow or by R.Vijayakumar
Published on 2009-10-30T09:39:01Z Indexed on 2010/03/24 5:03 UTC
Read the original article Hit count: 303

Filed under:
|
|
|
|

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 SimpleXMLDecoder(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 ?

© Stack Overflow or respective owner

Related posts about flex

Related posts about flash