<?xml version="1.0" encoding="UTF-8"?><!-- generator="wordpress/2.2.1" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: Dragging rows between two different Flex DataGrid controls</title>
	<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/</link>
	<description>A bunch of examples for Adobe Flex and ActionScript</description>
	<pubDate>Tue, 06 Jan 2009 12:22:43 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.2.1</generator>

	<item>
		<title>By: AK</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-16353</link>
		<author>AK</author>
		<pubDate>Wed, 22 Oct 2008 08:06:24 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-16353</guid>
		<description>I have a problem!
I have a page in which I need to place two pairs of datagrids(total four) with one column in each datagrid.
I need to drag an item from datagrid1 to datagrid2 ONLY and NOT to any other grid.
Similarly from datagrid3 to datagrid4 ONLY.
But when I tried, I can drag an item from datagrid1 to datagrid3, but interesting thing is that 
the data is not dropped into datagrid3 (instead a blank row is inserted), its getting lost from datagrid1.
How to solve this issue?</description>
		<content:encoded><![CDATA[<p>I have a problem!<br />
I have a page in which I need to place two pairs of datagrids(total four) with one column in each datagrid.<br />
I need to drag an item from datagrid1 to datagrid2 ONLY and NOT to any other grid.<br />
Similarly from datagrid3 to datagrid4 ONLY.<br />
But when I tried, I can drag an item from datagrid1 to datagrid3, but interesting thing is that<br />
the data is not dropped into datagrid3 (instead a blank row is inserted), its getting lost from datagrid1.<br />
How to solve this issue?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dave DuPlantis</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-16237</link>
		<author>Dave DuPlantis</author>
		<pubDate>Fri, 17 Oct 2008 20:34:00 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-16237</guid>
		<description>To expand on Peter's example (using buttons to move data from one list to another), you can do this with dynamic data. Note that in my code below, I actually have three lists, one on the left and two on the right (lists B and C), so I pass the list as a parameter, and I have a Left and Right button for list B (A to B, B to A) and another pair for list C (A to C, C to A).

Also note that MoveOnlyList is the name of the component I created as in Dante's example, so that items are never copied, always moved (my experience was that the destination list was the controller, so any list that received items had to be a MoveOnlyList).
&lt;pre class="code"&gt;
private function moveRight( destList:MoveOnlyList ):void {
    var item:Object = listOnTheLeft.selectedItem;
    if ( item ) {
        var acSource:ArrayCollection = ArrayCollection( listOnTheLeft.dataProvider );
        var idx:int = acSource.getItemIndex( item );
        var acDest:ArrayCollection;
        if ( destList.dataProvider == null ) {
            acDest = new ArrayCollection();
            destList.dataProvider = acDest;
        } else {
            acDest = ArrayCollection( destList.dataProvider );
        }
        acDest.addItem( item );
        acSource.removeItemAt( idx );
    }
}
&lt;/pre&gt;</description>
		<content:encoded><![CDATA[<p>To expand on Peter&#8217;s example (using buttons to move data from one list to another), you can do this with dynamic data. Note that in my code below, I actually have three lists, one on the left and two on the right (lists B and C), so I pass the list as a parameter, and I have a Left and Right button for list B (A to B, B to A) and another pair for list C (A to C, C to A).</p>
<p>Also note that MoveOnlyList is the name of the component I created as in Dante&#8217;s example, so that items are never copied, always moved (my experience was that the destination list was the controller, so any list that received items had to be a MoveOnlyList).</p>
<pre class="code">
private function moveRight( destList:MoveOnlyList ):void {
    var item:Object = listOnTheLeft.selectedItem;
    if ( item ) {
        var acSource:ArrayCollection = ArrayCollection( listOnTheLeft.dataProvider );
        var idx:int = acSource.getItemIndex( item );
        var acDest:ArrayCollection;
        if ( destList.dataProvider == null ) {
            acDest = new ArrayCollection();
            destList.dataProvider = acDest;
        } else {
            acDest = ArrayCollection( destList.dataProvider );
        }
        acDest.addItem( item );
        acSource.removeItemAt( idx );
    }
}
</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shikhar</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-15540</link>
		<author>Shikhar</author>
		<pubDate>Sat, 13 Sep 2008 06:53:30 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-15540</guid>
		<description>Hi can I move scroll bar while I am dragging row in data grid.
Please help me!
Thanks
Shikhar</description>
		<content:encoded><![CDATA[<p>Hi can I move scroll bar while I am dragging row in data grid.<br />
Please help me!<br />
Thanks<br />
Shikhar</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Anonymous</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-15441</link>
		<author>Anonymous</author>
		<pubDate>Wed, 10 Sep 2008 06:35:37 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-15441</guid>
		<description>thank you very mach!!</description>
		<content:encoded><![CDATA[<p>thank you very mach!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pex</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-14819</link>
		<author>pex</author>
		<pubDate>Wed, 20 Aug 2008 18:33:26 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-14819</guid>
		<description>Hi,
I'm looking for similar solution (dragging rows beetween two datagrids/lists) but based on native actionscript components (f.g. fl.controls.DataGrid) 

Is possible to use some components which supporting draggin events in native AS3? 
Have you got some?

Thanks for any help</description>
		<content:encoded><![CDATA[<p>Hi,<br />
I&#8217;m looking for similar solution (dragging rows beetween two datagrids/lists) but based on native actionscript components (f.g. fl.controls.DataGrid) </p>
<p>Is possible to use some components which supporting draggin events in native AS3?<br />
Have you got some?</p>
<p>Thanks for any help</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Marley</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-13923</link>
		<author>Robert Marley</author>
		<pubDate>Fri, 04 Jul 2008 12:58:05 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-13923</guid>
		<description>Great examples, thanks for that. 
I have a query perhaps someone can help with: 

I have 2 list controls and am dragging from one to the other. This is all fine.  The target list is configured to use an XMLList variable as it's data provider. 

When the list only contains 1 dropped item, the dataprovider is EMPTY.  

When it contains &#62; 1 item, the dataprovider contains the XML that I expect it would, namely the representation of the data that has been dropped. 

DataGrid shows the same issue. 

Any ideas? 

Thanks for any help,
SG</description>
		<content:encoded><![CDATA[<p>Great examples, thanks for that.<br />
I have a query perhaps someone can help with: </p>
<p>I have 2 list controls and am dragging from one to the other. This is all fine.  The target list is configured to use an XMLList variable as it&#8217;s data provider. </p>
<p>When the list only contains 1 dropped item, the dataprovider is EMPTY.  </p>
<p>When it contains &gt; 1 item, the dataprovider contains the XML that I expect it would, namely the representation of the data that has been dropped. </p>
<p>DataGrid shows the same issue. </p>
<p>Any ideas? </p>
<p>Thanks for any help,<br />
SG</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: peterd</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-13006</link>
		<author>peterd</author>
		<pubDate>Tue, 27 May 2008 07:38:37 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-13006</guid>
		<description>&lt;a href="http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-12988" rel="nofollow"&gt;Shalini&lt;/a&gt;,

This is a little rough, but should work:
&lt;pre class="code"&gt;
&#60;?xml version="1.0" encoding="utf-8"?&#62;
&#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&#62;

    &#60;mx:Script&#62;
        &#60;![CDATA[
            private function moveRight():void {
                var item:Object = dataGrid1.selectedItem;
                if (item) {
                    var idx:int = arrColl1.getItemIndex(item);
                    arrColl2.addItem(item);
                    arrColl1.removeItemAt(idx);
                }
            }

            private function moveLeft():void {
                var item:Object = dataGrid2.selectedItem;
                if (item) {
                    var idx:int = arrColl2.getItemIndex(item);
                    arrColl1.addItem(item);
                    arrColl2.removeItemAt(idx);
                }
            }
        ]]&#62;
    &#60;/mx:Script&#62;

    &#60;mx:Array id="arr"&#62;
        &#60;mx:Object label="One" /&#62;
        &#60;mx:Object label="Two" /&#62;
        &#60;mx:Object label="Three" /&#62;
        &#60;mx:Object label="Four" /&#62;
        &#60;mx:Object label="Five" /&#62;
    &#60;/mx:Array&#62;

    &#60;mx:ArrayCollection id="arrColl1" source="{arr}" /&#62;
    &#60;mx:ArrayCollection id="arrColl2" /&#62;

    &#60;mx:HBox&#62;
        &#60;mx:DataGrid id="dataGrid1"
                dataProvider="{arrColl1}"
                rowCount="5"&#62;
            &#60;mx:columns&#62;
                &#60;mx:DataGridColumn dataField="label" /&#62;
            &#60;/mx:columns&#62;
        &#60;/mx:DataGrid&#62;
        &#60;mx:VBox height="100%" verticalAlign="middle"&#62;
            &#60;mx:Button label="&#38;gt;&#38;gt;" click="moveRight();" /&#62;
            &#60;mx:Button label="&#38;lt;&#38;lt;" click="moveLeft();" /&#62;
        &#60;/mx:VBox&#62;
        &#60;mx:DataGrid id="dataGrid2"
                dataProvider="{arrColl2}"
                rowCount="5"&#62;
            &#60;mx:columns&#62;
                &#60;mx:DataGridColumn dataField="label" /&#62;
            &#60;/mx:columns&#62;
        &#60;/mx:DataGrid&#62;
    &#60;/mx:HBox&#62;

&#60;/mx:Application&#62;
&lt;/pre&gt;

Peter</description>
		<content:encoded><![CDATA[<p><a href="http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-12988" rel="nofollow">Shalini</a>,</p>
<p>This is a little rough, but should work:</p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            private function moveRight():void {
                var item:Object = dataGrid1.selectedItem;
                if (item) {
                    var idx:int = arrColl1.getItemIndex(item);
                    arrColl2.addItem(item);
                    arrColl1.removeItemAt(idx);
                }
            }

            private function moveLeft():void {
                var item:Object = dataGrid2.selectedItem;
                if (item) {
                    var idx:int = arrColl2.getItemIndex(item);
                    arrColl1.addItem(item);
                    arrColl2.removeItemAt(idx);
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="arr"&gt;
        &lt;mx:Object label="One" /&gt;
        &lt;mx:Object label="Two" /&gt;
        &lt;mx:Object label="Three" /&gt;
        &lt;mx:Object label="Four" /&gt;
        &lt;mx:Object label="Five" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:ArrayCollection id="arrColl1" source="{arr}" /&gt;
    &lt;mx:ArrayCollection id="arrColl2" /&gt;

    &lt;mx:HBox&gt;
        &lt;mx:DataGrid id="dataGrid1"
                dataProvider="{arrColl1}"
                rowCount="5"&gt;
            &lt;mx:columns&gt;
                &lt;mx:DataGridColumn dataField="label" /&gt;
            &lt;/mx:columns&gt;
        &lt;/mx:DataGrid&gt;
        &lt;mx:VBox height="100%" verticalAlign="middle"&gt;
            &lt;mx:Button label="&amp;gt;&amp;gt;" click="moveRight();" /&gt;
            &lt;mx:Button label="&amp;lt;&amp;lt;" click="moveLeft();" /&gt;
        &lt;/mx:VBox&gt;
        &lt;mx:DataGrid id="dataGrid2"
                dataProvider="{arrColl2}"
                rowCount="5"&gt;
            &lt;mx:columns&gt;
                &lt;mx:DataGridColumn dataField="label" /&gt;
            &lt;/mx:columns&gt;
        &lt;/mx:DataGrid&gt;
    &lt;/mx:HBox&gt;

&lt;/mx:Application&gt;
</pre>
<p>Peter</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Shalini</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-12988</link>
		<author>Shalini</author>
		<pubDate>Mon, 26 May 2008 12:11:35 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-12988</guid>
		<description>Hi Peter,am new to flex world and i find ur examples extremely helpful... i tried drag and drop but i have to get things done using  and  button... two grids with the buttons. Havent found a solution yet</description>
		<content:encoded><![CDATA[<p>Hi Peter,am new to flex world and i find ur examples extremely helpful&#8230; i tried drag and drop but i have to get things done using  and  button&#8230; two grids with the buttons. Havent found a solution yet</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kyle</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-12637</link>
		<author>Kyle</author>
		<pubDate>Mon, 12 May 2008 09:41:50 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-12637</guid>
		<description>Thanks! This was really helpful.</description>
		<content:encoded><![CDATA[<p>Thanks! This was really helpful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Marlene</title>
		<link>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-7505</link>
		<author>Marlene</author>
		<pubDate>Tue, 11 Mar 2008 19:38:37 +0000</pubDate>
		<guid>http://blog.flexexamples.com/2007/09/19/dragging-rows-between-two-different-flex-datagrid-controls/#comment-7505</guid>
		<description>Hello!

I an developing an application with a datagrid, which is populated dynamically as a result of a HTTPService request, creating the columns and inserting the rows. This request is triggered by a drop event from a list.
My idea was to remove columns from the datagrid, causing the data (column + rows) to refresh, by dragging a column "out" of the datagrid, but i don't know if such thing is possible... Can anyone help me? Thank you!</description>
		<content:encoded><![CDATA[<p>Hello!</p>
<p>I an developing an application with a datagrid, which is populated dynamically as a result of a HTTPService request, creating the columns and inserting the rows. This request is triggered by a drop event from a list.<br />
My idea was to remove columns from the datagrid, causing the data (column + rows) to refresh, by dragging a column &#8220;out&#8221; of the datagrid, but i don&#8217;t know if such thing is possible&#8230; Can anyone help me? Thank you!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
