1 Reply Latest reply on Jul 6, 2009 10:21 PM by kglad

    Loading data to DataGrid

    RVOIP

      Create a simple Datagrid using XML

         Take Datagrid instance name "myData"

       

      AS CODE

       

      //script starts here
      var myxml:XML = new XML();
      myxml.load("items.xml");
      myxml.ignoreWhite = true;
      myxml.onLoad = function(){
      var prod:Array = myxml.firstChild.childNodes;
      for(i=0;i<prod.length; i++){
      nam=prod[i].firstChild.childNodes[0];
      cost=prod[i].childNodes[1].firstChild.nodeValue;
      desc=prod[i].childNodes[2].firstChild.nodeValue;
      lock=prod[i].childNodes[3].firstChild.nodeValue;
      color=prod[i].childNodes[4].firstChild.nodeValue;
      myData.addItem({Product:nam, Price:cost, Type:lock, Color:color, Details:desc});
      }
      }

       

       

      XML CODE  (items.xml)

       

      <?xml version="1.0" encoding="ISO-8859-1"?>
      <catalog>
      <product>
      <title>Nokia 5310</title>
      <price>$159.99</price>
      <desc>2 MP Camera, MP3/Video Player with Warranty</desc>
      <type>Unlocked</type>
      <color>Blue </color>
      </product>

      <product>
      <title>Nokia 5800</title>
      <price>$399.99</price>
      <desc>U.S. 3G, 3.2 MP Camera, GPS, Wi-Fi, 8 GB MicroSD Card </desc>
      <type>Unlocked </type>
      <color>Black </color>
      </product>

      <product>
      <title>Nokia E63</title>
      <price>$199.99</price>
      <desc>2 MP Camera, 3G, Wi-Fi, Media Player, Version with Warranty </desc>
      <type>Unlocked Cell </type>
      <color>Blue </color>
      </product>

      <product>
      <title>Motorola RIZR Z3</title>
      <price>$24.99</price>
      <desc>2 MP Camera, MP3/Video Player, MicroSD Slot--International Version </desc>
      <type>locked (AT&T)</type>
      <color>Black </color>
      </product>

      <product>
      <title>Motorola RAZR V3 </title>
      <price>$79.99</price>
      <desc>With Camera, Video Player--International Version with Warranty</desc>
      <type>Unlocked</type>
      <color>Silver</color>
      </product>

      <product>
      <title>Motorola ROKR E6</title>
      <price>$249.99</price>
      <desc>2 MP Camera, MP3/Video Player, SD Slot--International Version </desc>
      <type>Unlocked </type>
      <color>Black </color>
      </product>


      <product>
      <title>Samsung SGH-D900i</title>
      <price>$137.52</price>
      <desc>3.2 MP Camera, Media Player, MicroSD Slot--International Version with No Warranty </desc>
      <type>Unlocked </type>
      <color>Silver</color>
      </product>

      <product>
      <title>BlackBerry Storm 9500</title>
      <price>$49.99</price>
      <desc>3.2 MP Camera, GPS, MicroSD Slot, RIM -- International Version - Without Warranty </desc>
      <type>locked(Verizon)</type>
      <color>Black</color>
      </product>

      <product>
      <title>Blackberry Pearl 8110</title>
      <price>$228.99</price>
      <desc>Quad-Band, EDGE, QWERTY Keyboard, Bluetooth, MicroSD Card Slot </desc>
      <type>Unlocked GSM </type>
      <color>RED</color>
      </product>

      <product>
      <title>Nokia N72 </title>
      <price>$210.42</price>
      <desc>2 MP Camera, MP3/Video Player, SD/MMC--International Version with Warranty</desc>
      <type>Unlocked</type>
      <color>Black</color>
      </product>

      <product>
      <title>Nokia N95 </title>
      <price>$389.99</price>
      <desc>8GB Multimedia Cell Phone - 3G, 5 Megapixel Camera, Quad Band </desc>
      <type>Unlocked GSM </type>
      <color>Black</color>
      </product>
      </catalog>