3 Replies Latest reply on Oct 19, 2007 8:55 AM by ntsiii

    Two Datagrids, Multiple Provider Issue

    NeoSpawn
      What Im trying to do is when when DataGrid1 has an item selected it fills out a series of text boxes and another DataGrid. All the data is in XML, so when I click on one element, to access the proper element i go data_grid1.selectedItem.state

      But for the second DataGrid the data that goes into there is:
      <people>
      <person email=...>
      </people>

      and the dataPovider i use is data_grid1.selectedItem.people, I get Multiple initializers for property 'dataProvider'. (note: 'dataProvider' is the default property of 'mx.controls.DataGrid')

      In this example I tried doing what he did and his examples compile with no problems but I dont know how to do that for myself, what am I doing wrong?

      <?xml version="1.0" encoding="UTF-8"?>
      <mx:Application xmlns:flexlib=" http://code.google.com/p/flexlib/" xmlns="*" xmlns:mx=" http://www.adobe.com/2006/mxml" height="100%" width="100%" applicationComplete="getXML()">
      <mx:Script>
      <![CDATA[
      import mx.rpc.http.HTTPService;
      import mx.rpc.events.FaultEvent;
      import mx.rpc.events.ResultEvent;
      import mx.controls.Alert;

      public function getXML():void
      {
      var serv:HTTPService = new HTTPService();
      serv.contentType="application/xml";
      serv.url="contacts.xml";
      //serv.useProxy=false;
      serv.resultFormat="xml";
      serv.addEventListener("result",gotResult);
      serv.addEventListener("fault",gotFault);
      serv.send();
      }

      private function gotFault(event:FaultEvent):void
      {
      Alert.show(event.fault.message);
      }
      [Bindable]
      var myXML:XML;

      private function gotResult(event:ResultEvent):void
      {
      myXML = new XML(event.result);
      //avListing.dataProvider = myXML.contact;
      }

      public function searchAndReplace(holder:String):String
      {
      var searchfor:String="\t";
      var replacement:String="";
      var temparray:Array= holder.split(searchfor);
      var holder:String = temparray.join(replacement);
      searchfor="\r";

      temparray= holder.split(searchfor);
      holder = temparray.join(replacement);
      return (holder);
      }
      ]]>
      </mx:Script>
      <mx:Binding source="myXML.contact" destination ="avListing.dataProvider"/>
      <mx:Binding source="avListing.selectedItem.people as XML" destination="grid_contacts.dataProvider"/>
      <mx:HBox width="100%" height="100%">

      <mx:DataGrid id="avListing" width="25%" height="100%">
      <mx:columns>
      <mx:DataGridColumn dataField="state" headerText="State"/>
      </mx:columns>
      </mx:DataGrid>
      <mx:TextArea id="box_State" text="{avListing.selectedItem.state}" width="100" height="20"/>
      <mx:TextArea id="box_Address" text="{searchAndReplace(avListing.selectedItem.address)}" width="250" height="100"/>


      <mx:DataGrid id="grid_contacts" width="300" height="100">
      <mx:DataGridColumn dataField="person" headerText="Person"/>
      </mx:DataGrid>



      </mx:HBox>
      </mx:Application>