views:

225

answers:

4

I have an AdvancedDataGrid with XML dataProvider. Drag and drop in enabled, and works within the visible rows of the ADG.

HOWEVER, if I attempt to drag an item past the bottom-most visible row of the ADG, the ADG does NOT scroll to display the next rows, which makes it impossible to drag and drop beyond the immediately visible rows. Although this would seem to be logical default behaviour of a datagrid (drag to bottom and keep dragging to reveal subsequent rows), Flex evidently doesn't Do Things That Way. I'm flummoxed how to implement this programatically.

Can anyone help?

+1  A: 

I had to do this with a few items in the past, basically what I did was monitor the mouses Y position in the DG, if it was 50 or fewer pixels from the top or bottom then I would set the verticalscrollposition of the DG += 20 or -= 20 as required.

Let me know if you need a code snip but you should be able to figure out how to do all of this.

invertedSpear
yeah cool. want thinking co-ordinate-space, was doing all my calc in dataspace which overcomplicates everything thanks
Darrell Berry
A: 

Hi invertedSpear,

I'm facing the same issue , could you please share the code snippet so that it clears the things for me and helps me to understand how to work this through.

Thanks a ton for you help on this.

Saggi_sweet
A: 

Got to love Flex, man. Where the obvious stuff takes a ton of time.

So this is what I ended up doing:

mygrid.addEventListener( DragEvent.DRAG_OVER, handleDragOver);



public function handlerDragOver(event:DragEvent):void{
var dropIndex:int        = mygrid.calculateDropIndex(event);
var rowsDisplayed:Number = mygrid.rowCount;
var topvisibleIndex:int  = mygrid.verticalScrollPosition;
var botvisibleIndex:int  = topvisibleIndex + rowsDisplayed;


if ( dropIndex <= topvisibleIndex) {

    mygrid.verticalScrollPosition = Math.max( mygrid.verticalScrollPosition- 1, 0 );

} else if( dropIndex >= botvisibleIndex - 1 ){

mygrid.verticalScrollPosition += 1;
}

}

Andre deBruin
A: 

Brilliant! Thanks.

Arnold Aprieto