8 Replies Latest reply on May 22, 2007 3:46 PM by dimival

    Custom Component dataProvider

    shaungish Level 1
      Here's the code I have so far:

      Main Application file:
      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute" xmlns:comp="components.*">
      <mx:Script>
      <![CDATA[
      import mx.rpc.events.*;
      import mx.collections.ArrayCollection;
      import mx.rpc.events.ResultEvent;
      import mx.events.*;

      [Bindable]
      public var customers:ArrayCollection = null;

      public function customersRPCResult(event:ResultEvent):void
      {
      customers = new ArrayCollection();
      customers = event.result.customers.person as ArrayCollection;
      }

      public function customersRPCFaultHandler(event:FaultEvent):void
      {

      }
      ]]>
      </mx:Script>
      <!--customers.php - provides xml data for customers:ArrayCollection-->
      <mx:HTTPService id="customersRPC" url="assets/customers.php" result="customersRPCResult(event)" fault="customersRPCFaultHandler(event)" />
      <comp:CustomerInfo creationComplete="customersRPC.send()" customerInfo.dataProvider="{customers}" />
      </mx:Application>

      CustomerInfo.mxml - this is the component that I'm trying to set the dataProvider of the dataGrid for
      <?xml version="1.0" encoding="utf-8"?>
      <mx:VBox xmlns:mx=" http://www.adobe.com/2006/mxml">
      <mx:HBox width="100%" height="34">
      <mx:Label text="Filter Data"/>
      <mx:TextInput id="customerFilterText"/>
      <mx:Button label="Clear"/>
      <mx:Button label="Refresh"/>
      </mx:HBox>
      <mx:HBox width="100%" height="100%">
      <mx:DataGrid width="100%" height="197" id="customerInfo">
      <mx:columns>
      <mx:DataGridColumn headerText="Last" dataField="last"/>
      <mx:DataGridColumn headerText="First" dataField="first"/>
      <mx:DataGridColumn headerText="Home" dataField="home"/>
      </mx:columns>
      </mx:DataGrid>
      </mx:HBox>
      </mx:VBox>