滚动时固定列标题-jqgrid [英] fixing column headers while scrolling - jqgrid

查看:72
本文介绍了滚动时固定列标题-jqgrid的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我的网格数据在当前窗口上滚动,是否有可能在滚动数据时冻结列标题,以使列标题始终可见(如excel中).我正在使用height:'auto',因为我不想固定网格高度.预先感谢...

If my grid data scrolls over the current window, is it possible to freeze the column headers while scrolling the data so that column headers are always visible(like in excel). I am using height: 'auto' because I did not want to fix my grid height. Thanks in advance...

推荐答案

如果网格是页面上最顶层的元素,则使用position: fixed可能会有所帮助.该代码可能与以下内容有关

If the grid is top-most element on the page then the usage of position: fixed can be helpful. The code could be about the following

var $hdiv = $($grid[0].grid.hDiv),
    hOffset = $hdiv.offset(),
    $cdiv = $($grid[0].grid.cDiv),
    cOffset = $cdiv.offset(),
    $bdiv = $($grid[0].grid.bDiv);
// change gbox position
$bdiv.parent().parent().css({
    position: "relative",
    top: $bdiv.offset().top,
    left: 0});
// make header and capture fixed
$hdiv.css({
    position: "fixed",
    zIndex: 1,
    top: hOffset.top - cOffset.top,
    left: hOffset.left
});
$cdiv.css({
    position: "fixed",
    zIndex: 1,
    top: 0,
    left: cOffset.left,
    width: $cdiv.width()
});

请参见演示.

这篇关于滚动时固定列标题-jqgrid的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆