1 Reply Latest reply on Feb 12, 2008 2:04 PM by Gregory Lafrance

    Data BInding with dataGrid

    mariflux2
      HI, any one know how to binding dataProvider of a dataGrid with a arrayCollection???
        • 1. Re: Data BInding with dataGrid
          Gregory Lafrance Level 6
          <?xml version="1.0"?>
          <!-- dpcontrols/DataGridPassData.mxml -->
          <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml"
          initialize="initData()">
          <mx:Script>
          <![CDATA[
          import mx.collections.*;
          private var DGArray:Array = [
          {Artist:'Pavement', Album:'Slanted and Enchanted', Price:11.99},
          {Artist:'Pavement', Album:'Brighten the Corners', Price:11.99}];

          [Bindable]
          public var initDG:ArrayCollection;
          //Initialize initDG ArrayCollection variable from the Array.
          //You can use this technique to convert an HTTPService,
          //WebService, or RemoteObject result to ArrayCollection.
          public function initData():void {
          initDG=new ArrayCollection(DGArray);
          }
          ]]>
          </mx:Script>

          <mx:DataGrid id="myGrid" width="350" height="200"
          dataProvider="{initDG}" >
          <mx:columns>
          <mx:DataGridColumn dataField="Album" />
          <mx:DataGridColumn dataField="Price" />
          </mx:columns>
          </mx:DataGrid>
          </mx:Application>