I believe there already is a bug on that issue.

 

________________________________

From: flexcoders@yahoogroups.com [mailto:[EMAIL PROTECTED] On
Behalf Of y x
Sent: Wednesday, July 02, 2008 2:22 PM
To: flexcoders@yahoogroups.com
Subject: [flexcoders] about the datagrid will auto scroll after
drag-droped

 

Hi all,
    here is the test application: drag some data from the left list to
the 
datagrid until it display a vertical srollbar, then, as the mouse moved
(not 
click down), the datagrid will response the mousemove event and scroll.

    the scrollbar will not response the movement of the mouse if the
data is 
no dragged into the grid. so ,I think the  datagrid was added  a
listener to 
response the mouse movement for the drop action.

    so, anyone knows how can I remove this listener as the drop is over?

    Thanks!

Speed
2008-07-02

---------------the test application code----------------------
<?xml version="1.0"?>
<!-- dragdrop\DandDListToDG.mxml -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml
<http://www.adobe.com/2006/mxml> "
    creationComplete="initApp();">

    <mx:Script>
        <![CDATA[
            import mx.events.DragEvent;
            import mx.managers.DragManager;
            import mx.core.DragSource;
            import mx.collections.IList;
            import mx.collections.ArrayCollection;

            private function initApp():void {
                srcList.dataProvider = new ArrayCollection([
                    {label:"First", data:"1"},
                    {label:"Second", data:"2"},
                    {label:"Third", data:"3"},
                    {label:"Fourth", data:"4"},
                    {label:"Fourth", data:"4"},
                    {label:"Fourth", data:"4"},
                    {label:"Fourth", data:"4"},
                    {label:"Fourth", data:"4"},

                ]);

                destDG.dataProvider = new ArrayCollection([]);
            }

            private function dragDropHandler(event:DragEvent):void {
              if (event.dragSource.hasFormat("items"))
              {
                // Explicitly handle the dragDrop event.
                event.preventDefault();

                // Since you are explicitly handling the dragDrop event,
                // call hideDropFeedback(event) to have the drop target
                // hide the drop indicator.
                // The drop indicator is created
                // automatically for the list controls by the built-in
                // event handler for the dragOver event.
                event.currentTarget.hideDropFeedback(event);

                // Get drop target.
                var dropTarget:DataGrid =
                  DataGrid(event.currentTarget);

                var itemsArray:Array =
                    event.dragSource.dataForFormat('items') as Array;
                var tempItem:Object =
                    { label: itemsArray[0].label,
                      data: itemsArray[0].data,
                      date: new Date()
                    };

                // Get the drop location in the destination.
                var dropLoc:int = dropTarget.calculateDropIndex(event);

                IList(dropTarget.dataProvider).addItemAt(tempItem,
dropLoc);
              }
            }
        ]]>
    </mx:Script>

    <mx:HBox>
        <mx:List  id="srcList"
            dragEnabled="true"
            dragMoveEnabled="true"/>

        <mx:DataGrid  id="destDG"  dragMoveEnabled="true"
dragEnabled="true"
            dropEnabled="true"
            dragDrop="dragDropHandler(event);">
            <mx:columns>
                <mx:DataGridColumn dataField="label"/>
                <mx:DataGridColumn dataField="data"/>
                <mx:DataGridColumn dataField="date"/>
            </mx:columns>
        </mx:DataGrid>
    </mx:HBox>

    <mx:Button id="b1"
        label="Reset"
        click="initApp()"
    />

</mx:Application> 

 

Reply via email to