This is a migrated thread and some comments may be shown as answers.

Cannot scroll while dragging

4 Answers 121 Views
Grid
This is a migrated thread and some comments may be shown as answers.
James
Top achievements
Rank 1
James asked on 17 Mar 2011, 03:22 PM
If you have a rad grid that has say 100 items which causes the page to scroll, if you try to drag an item from the bottom of the rad grid to another rad grid that is not visible (due to the scrolling) the page does not scroll.

I know that this is a browser issue rather than a radgrid issue, but does anyone have a good workaround?

thanks

james

4 Answers, 1 is accepted

Sort by
0
Galin
Telerik team
answered on 22 Mar 2011, 09:38 PM
Hi James,

Our RadGrid supports auto scroll inside the grid, but does not support custom events outside of it. You can use the following javascript sample to implement this feature:
var viewportHeight =  document.documentElement.clientHeight || document.body && document.body.clientHeight;
 
function mouseObserver(e) {
    if(e.clientY < 50){document.documentElement.scrollTop -= 20}
    else if(e.clientY > viewportHeight - 50){document.documentElement.scrollTop += 20}
}

Also, add this attribute to ClientSettings > ClientEvents:
OnRowDragStarted="function(){document.body.onmousemove = function(e){mouseObserver(e)}}"

I hope this helps.

Best wishes,
Galin
the Telerik team
0
James
Top achievements
Rank 1
answered on 30 Sep 2011, 08:50 AM
hi, sorry for the late reply - just implementing this in a different project from the one in march.

I have had a problem with the clientY bit in IE8. the below javascript seems to work pretty well though

 

var viewportHeight = document.documentElement.clientHeight || document.body && document.body.clientHeight;

 

 

 

// Detect if the browser is IE or not.

 

// If it is not IE, we assume that the browser is NS.

var

 

IE = document.all?true:false

 

// If NS -- that is, !IE -- then set up for mouse capture

if

 

(!IE) document.captureEvents(Event.MOUSEMOVE)

 

// Temporary variables to hold mouse x-y pos.s

var

 

tempX = 0

 

var

 

tempY = 0

 

function

 

mouseObserver(e) {

 

if

 

(IE) { // grab the x-y pos.s if browser is IE

 

tempX =

event.clientX + document.body.scrollLeft

 

tempY =

event.clientY + document.body.scrollTop

 

}

else { // grab the x-y pos.s if browser is NS

 

tempX = e.pageX

tempY = e.pageY

}

 

// catch possible negative values in NS4

 

 

if (tempX < 0){tempX = 0}

 

 

if (tempY < 0){tempY = 0}

 

 

 

if(tempY < 50){document.documentElement.scrollTop -= 20}

 

 

else if(tempY > viewportHeight - 50){document.documentElement.scrollTop += 20}

 

}

0
James
Top achievements
Rank 1
answered on 14 Oct 2011, 11:51 AM
i just noticed that the scrolling continues if you drop a row onto a group header row or header row. you need to stop observing the event onrowdropping
0
Galin
Telerik team
answered on 19 Oct 2011, 02:12 PM
Hello James,

You can break the element with the following js:
OnRowDropped="function(){document.body.onmousemove = ''}"

I hope this helps.

Best wishes,
Galin
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
James
Top achievements
Rank 1
Answers by
Galin
Telerik team
James
Top achievements
Rank 1
Share this question
or