Auto-Scrolling Issue in ADG while drag/drop

As the title suggests, this is an article about the issue that you may encounter while using SDK 3.x  and AdvancedDataGrid.

Unlike other list based components like TileList , DG etc, vertical scroll bar doesnt moves automatically to the last of the  row item while drag/drop onto the ADG. 

This can be an issue when you have a situation [and most of the time , it can be ] when you have only few visible rows and you want to drag and drop a row /item somewhere in that ADG , not necessarily between the current visible set , you expect that Scroll should move till the last row on its own.  In ADG it does not happens , because of one bug which have been already logged here.

https://bugs.adobe.com/jira/browse/FLEXDMV-2471   — if you want to vote/keep a watch on to it.

Workaround is :

Please override the function showDropFeedback and then

change this line
if (collection)
dragScroll();

To

if (collection)
if (dragScrollingInterval == 0)
dragScrollingInterval = setInterval(dragScroll, 15);

Hope this helps somebody facing this issue.

2 Responses to Auto-Scrolling Issue in ADG while drag/drop

  1. Santanu Karar says:

    There’s no ‘dragScrollingInterval’ public with SDK 4.1. Actually there’s no full proof solution yet.

  2. Robb Cundick says:

    I found a way to get around dragScrollingInterval being private.

    1. Create a new class descended from AdvancedDataGrid.

    2. Declare private var dragScrollingInterval:int = 0; in your derived class.

    3. Override showDropFeedback as follows:

    override public function showDropFeedback(event:DragEvent):void
    {
    if (collection) {
    if (dragScrollingInterval == 0) {
    dragScrollingInterval = setInterval(dragScroll, 15);
    }
    }
    super.showDropFeedback(event);
    }

    4. Override dragScroll, copying the code exactly from AdvancedListBaseClass. This function will now use the version of dragScrollingInterval you have created in your derived class. (Do not call super.dragScroll — you are replacing the function in AdvancedListBaseClass).

    5. Override mouseUpHandler to reset your internal dragScrollingInterval variable to 0 when the mouse is released. Otherwise once you’ve dragged once, the window will continue to scroll whenever you move the mouse moves outside the window.

    override protected function mouseUpHandler(event:MouseEvent):void
    {
    super.mouseUpHandler(event);
    dragScrollingInterval = 0;
    }