1 Reply Latest reply on Aug 22, 2011 1:03 AM by Vibhuti Gosavi(InfoCepts)

    how to move a selected row data from one grid to another grid using button click handler in flex4

    Venkatesan Balasubramanian Level 1

      hi friends,

       

      i am doing flex4 mxml web application,

       

      i am struck in this concept please help some one.

       

      i am using two seperated forms and each form having one data grid.

       

      In first datagrid i am having 5 rows and one button(outside the data grid with lable MOVE). when i am click a row from the datagrid and click the MOVE button means that row should disable from the present datagrid and that row will go and visible in  the second datagrid.

       

      i dont want drag and drop method, i want this process only using button click handler.

       

      how to do this?

       

      any suggession or snippet code are welcome.

       

       

      Thanks,

      B.venkatesan.

        • 1. Re: how to move a selected row data from one grid to another grid using button click handler in flex4
          Vibhuti Gosavi(InfoCepts) Level 3

          Hi,

           

          You can get an idea from foolowing code and also from the link which i am providing.

           

          Code:

           

          <?xml version="1.0" encoding="utf-8"?>

          <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute"

          width="613" height="502" viewSourceURL="../files/DataGridExampleCinco.mxml">

           

           

           

          <mx:Script>

          <![CDATA[

          import mx.collections.ArrayCollection;

          import mx.binding.utils.BindingUtils;

           

          [Bindable]

          private var allGames:ArrayCollection;

           

          [Bindable]

          private var selectedGames:ArrayCollection;

           

          private function initDGAllGames():void

          {

          allGames = new ArrayCollection();

          allGames.addItem({name: "World of Warcraft",

          creator: "Blizzard", publisher: "Blizzard"});

          allGames.addItem({name: "Halo",

          creator: "Bungie", publisher: "Microsoft"});

          allGames.addItem({name: "Gears of War",

          creator: "Epic", publisher: "Microsoft"});

          allGames.addItem({name: "City of Heroes",

          creator: "Cryptic Studios", publisher: "NCSoft"});

          allGames.addItem({name: "Doom",

          creator: "id Software", publisher: "id Software"});

           

          }

           

          protected function button1_clickHandler(event:MouseEvent):void

          {

           

          BindingUtils.bindProperty(dgSelectedGames,"dataProvider" ,dgAllGames ,"selectedItems");

           

          }

           

          ]]>

          </mx:Script>

           

           

          <mx:Label x="11" y="67" text="All our data"/>

          <mx:Label x="10" y="353" text="Selected Data"/>

           

          <mx:Form x="144" y="10" height="277">

          <mx:DataGrid id="dgAllGames" width="417" height="173"

          creationComplete="{initDGAllGames()}" dataProvider="{allGames}" editable="false">

          <mx:columns>

          <mx:DataGridColumn headerText="Game Name" dataField="name" width="115"/>

          <mx:DataGridColumn headerText="Creator" dataField="creator"/>

          <mx:DataGridColumn headerText="Publisher" dataField="publisher"/>

          </mx:columns>

          </mx:DataGrid>

          <mx:FormItem label="Label">

          <mx:Button label="Move" click="button1_clickHandler(event)"/>

          </mx:FormItem>

          </mx:Form>

           

          <mx:Form x="120" y="333">

          <mx:DataGrid id="dgSelectedGames" width="417" height="110" >

           

          <mx:columns>

          <mx:DataGridColumn headerText="Game Name" dataField="name" width="115"/>

          <mx:DataGridColumn headerText="Creator" dataField="creator"/>

          <mx:DataGridColumn headerText="Publisher" dataField="publisher"/>

          </mx:columns>

          </mx:DataGrid>

          </mx:Form>

           

          </mx:Application>

          Link:
          Thanks and Regards,
          -----------------------------------------------------------------------------------------
          Vibhuti Gosavi | vgosavi@infocepts.com | www.infocepts.com
          -----------------------------------------------------------------------------------------