vendredi 27 novembre 2015

How can be a ArrayCollection created?

There is a nice example of Advanced Datagrid and use of ArrayCollection here. I like to have something like that;

private var dpFlat:ArrayCollection = new ArrayCollection([
{Region:"Southwest", Territory:"Arizona", 
  Territory_Rep:"Barbara Jennings", Actual:38865, Estimate:40000}, 
{Region:"Southwest", Territory:"Arizona", 
  Territory_Rep:"Dana Binn", Actual:29885, Estimate:30000},  
{Region:"Southwest", Territory:"Central California", 
  Territory_Rep:"Joe Smith", Actual:29134, Estimate:30000},  
{Region:"Southwest", Territory:"Nevada", 
  Territory_Rep:"Bethany Pittman", Actual:52888, Estimate:45000},  
{Region:"Southwest", Territory:"Northern California", 
  Territory_Rep:"Lauren Ipsum", Actual:38805, Estimate:40000}, 
{Region:"Southwest", Territory:"Northern California", 
  Territory_Rep:"T.R. Smith", Actual:55498, Estimate:40000},  
{Region:"Southwest", Territory:"Southern California", 
  Territory_Rep:"Alice Treu", Actual:44985, Estimate:45000}, 
{Region:"Southwest", Territory:"Southern California", 
  Territory_Rep:"Jane Grove", Actual:44913, Estimate:45000}
]);

I need to read an XML file and get some attributes from it. Then create a custom ArrayCollection with these attributes. Right now I am creating a custom XML but I no longer want to use XML and instead check Array Collection.

Here is the code I read and create another XML;

kitapKonuSayisi = _tempXMLOR.Body.Ogrenci.length();

for(var itra:int = 0; itra < kitapKonuSayisi; itra++)
{
    uniteAdi = _tempXMLOR.Body.Ogrenci[itra].UniteAdi;
    konuAdi  = _tempXMLOR.Body.Ogrenci[itra].KonuAdi;
    ogrenciAyrintiRaporArray.push([uniteAdi, konuAdi]);
}

for(var itrc:int = 0; itrc < kitapKonuSayisi; itrc++)
{
    kitapUniteSayisi = _tempXMLOR.Body.Ogrenci[itrc].UniteAdi.length();
    uniteAdi = _tempXMLOR.Body.Ogrenci[itrc].UniteAdi;
    if(raporStringUnitCheck === true)
    {
        ogrenciAyrintiRaporStr += ('\t<Unite name="' + uniteAdi + '" yuzde="' + 100 + '">\n');
        raporStringUnitCheck = false;
    }

    for(var itrd:int = 0; itrd < kitapUniteSayisi; itrd++)
    {
        if(ogrenciAyrintiRaporArray[itrd][0] == _tempXMLOR.Body.Ogrenci[itrc].UniteAdi)
        {
            konuAdi = _tempXMLOR.Body.Ogrenci[itrc].KonuAdi;
            ogrenciAyrintiRaporStr += ('\t\t<Konu name="' + konuAdi + '" yuzde="' + 100 + '"/>\n');
        }
    }
}
if(raporStringUnitCheck === false && raporStringCompCheck === false)
{
    ogrenciAyrintiRaporStr += ('\t</Unite>\n');
    ogrenciAyrintiRaporStr += ('</Rapor>');
    raporStringCompCheck = true;
    raporString2XML = new XML(ogrenciAyrintiRaporStr);
}

So how can I create ArrayCollection and populate elements in that scheme?

Aucun commentaire:

Enregistrer un commentaire