2 Replies Latest reply on Jul 6, 2006 9:20 PM by TIPLVinay

    Data Grid this time

    TIPLVinay Level 1
      doing R&D with Flex 2.0
      someone has posted the below example.
      How we can transfer the selected row from one to another DataGrid when click on load button
      wht is wrong in the code

      <?xml version="1.0" encoding="utf-8"?>
      <mx:Application xmlns:mx=" http://www.adobe.com/2006/mxml" layout="absolute">

      <mx:DataGrid x="10" y="28" width="209" dataProvider="{sourceData}" id="sourceDG">
      <mx:columns>
      <mx:DataGridColumn headerText="Name" dataField="name"/>
      <mx:DataGridColumn headerText="Id" dataField="id"/>
      <mx:DataGridColumn headerText="Role" dataField="role"/>
      </mx:columns>
      </mx:DataGrid>

      <mx:Script>
      <![CDATA[
      import mx.collections.ArrayCollection;

      [Bindable]
      public var sourceData:Array = [{name:"magie1", id:"1234", role:"xyz1"},
      {name:"magie2", id:"1235", role:"xyz2"},
      {name:"magie4", id:"1237", role:"xyz4"},
      {name:"magie5", id:"1238", role:"xyz5"}];

      [Bindable]
      public var targetData:ArrayCollection;

      public function load() : void {
      targetData.addItem(sourceDG.dataProvider[sourceDG.selectedIndex]);
      }
      ]]>
      </mx:Script>

      <mx:DataGrid x="248" y="28" dataProvider="{targetData}" width="209" id="targetDG">
      <mx:columns>
      <mx:DataGridColumn headerText="Name" dataField="name"/>
      <mx:DataGridColumn headerText="Id" dataField="id"/>
      <mx:DataGridColumn headerText="Role" dataField="role"/>
      </mx:columns>
      </mx:DataGrid>
      <mx:Button x="201" y="237" click="load()" label="Load"/>
      </mx:Application>

      i hv also tried with :-

      1) targetData.addItem(sourceDG.dataProvider[sourceDG.selectedItem]);

      and other array to object conversions
      but in vain..

      can any one ..

      TIA

      vinay Sharma