DIV中表格数据逐列移动

  var jzltimer, jzrtimer;
var jzDivList;
var jzlArray, jzrArray;
function ScrollLeft()
{ 
    if(event != null)
    {
        jzDivList = null;  // 页面切换时用到
    }
    OneLeftColMove();
    jzltimer = setTimeout('ScrollLeft()', 1000); //这里20为滚动间隔时间(毫秒)
}

/*
 * 滚动一次, 向左移动一列
 */
function ScrollRight()
{ 
    if(event != null)
    {
        jzDivList = null;  // 页面切换时用到
    }
    OneRightColMove();
    jzrtimer = setTimeout('ScrollRight()', 1000); //这里20为滚动间隔时间(毫秒)
}

function InitScroll()
{
    jzDivList = event.srcElement.parentElement.parentElement.previousSibling.cells(0).children(0);
    if(jzDivList.innerHTML == "")
    {
        return;
    }
    var cols = jzDivList.children[0].rows[0].cells;
    jzlArray = new Array();
    jzrArray = new Array();
    for(var i=1; i<cols.length; i=i+1)
    {
        if(jzDivList.children[0].rows[0].offsetWidth < jzDivList.offsetWidth + cols[i].offsetLeft)
        {
            jzlArray.push(jzDivList.children[0].rows[0].offsetWidth - jzDivList.offsetWidth);
            break;
        }
        jzlArray.push(cols[i].offsetLeft);
    }
    jzrArray.push(jzDivList.children[0].rows[0].offsetWidth - jzDivList.offsetWidth);
    for(var i=cols.length-1; i>=0; i=i-1)
    {
        jzrArray.push(cols[i].offsetLeft - jzDivList.offsetWidth);
        if(jzrArray[jzrArray.length - 1] < 0)
        {
            jzrArray[jzrArray.length - 1] = 0;
            break;
        }
    }
}
/*
 * 滚动一次, 向右移动一列
 */
function StopScroll()
{
    if(jzltimer != null)
    {
        clearTimeout(jzltimer);
    }
    
    if(jzrtimer != null)
    {
        clearTimeout(jzrtimer);
    }
}
/*
 * 点击一下, 向左移动一列
 */
function OneLeftColMove()
{
    if(jzDivList == null)
    {
        InitScroll();
    }
    if(jzDivList.innerHTML == "")  // 内容为空
    {
        return;
    }
    for(var i=0; i<jzlArray.length; i=i+1)
    {
        if(jzDivList.scrollLeft < jzlArray[i])
        {
            jzDivList.scrollLeft = jzlArray[i];
            break;
        }
    }
}
/*
 * 点击一下, 向右移动一列
 */
function OneRightColMove()
{
    if(jzDivList == null)
    {
        InitScroll();
    }
    if(jzDivList.innerHTML == "")  // 内容为空
    {
        return;
    }
    for(var i=0; i<jzrArray.length; i=i+1)
    {
        if(jzDivList.scrollLeft > jzrArray[i])
        {
            jzDivList.scrollLeft = jzrArray[i];
            break;
        }
    }
}

在.NET中,一个GridView如果有多列数据,但又不想让它完全显示
也不想出现横向滚动条,当鼠标经过对象时移动一列
如图所示

你可能感兴趣的:(.net)