实现方式:
当拖动的时候判断是否拖出表格,如果拖出表格,就让滚动条自动滚动:
var intervalId;
....
if(currentPosition > bottomBorder){
intervalid = setInterval(autoscrollto(true),100);
}else if(currentPosition < topBorder){
intervalId = setInterval(autoscrollto(false),100);
}
//direction 值为true 表示向下滚动,false表示向上滚动
function autoScrollTo(direction){
var scrollHeight = 30;
if(!direction){
scrollHeight = -30;
}
var scrollparent = $("#mygrid").scrollparent();
scrollparent.scrollTop(scrollparent.scrollTop()+scrollHeight);
}
当放下拖动对象或者重新拖动到表格里边时调用 clearInterval(intervalId)方法, 此方法可以把循环调用终止,不让滚动条继续滚动.
当拖动的时候判断是否拖出表格,如果拖出表格,就让滚动条自动滚动:
var intervalId;
....
if(currentPosition > bottomBorder){
intervalid = setInterval(autoscrollto(true),100);
}else if(currentPosition < topBorder){
intervalId = setInterval(autoscrollto(false),100);
}
//direction 值为true 表示向下滚动,false表示向上滚动
function autoScrollTo(direction){
var scrollHeight = 30;
if(!direction){
scrollHeight = -30;
}
var scrollparent = $("#mygrid").scrollparent();
scrollparent.scrollTop(scrollparent.scrollTop()+scrollHeight);
}
当放下拖动对象或者重新拖动到表格里边时调用 clearInterval(intervalId)方法, 此方法可以把循环调用终止,不让滚动条继续滚动.