使用firefox在asp.net中的freeZe gridview标头 [英] freeZe gridview header in asp.net using firefox

查看:63
本文介绍了使用firefox在asp.net中的freeZe gridview标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用firefox在asp.net中的freeZe gridview标头我的gridview标头已在ie8中修复,但相同的脚本在firefox中不起作用

freeZe gridview header in asp.net using firefox my gridview header is fixd in ie8 but same script not wrok in firefox

.FrozenHeader
       {
         background-color:Gray;
           position: relative;
           cursor: default;
           top:auto;
           z-index: 10;
          top:expression(this.parentNode.parentNode.parentNode.scrollTop-1);
       }


Firefox的任何解决方案?


any solution for firefox?

推荐答案

<style type="text/css">
    .WrapperDiv {
        width:800px;height:400px;border: 1px solid black;
    }
    .WrapperDiv TH {
        position:relative;
    }
    .WrapperDiv TR
    {
        /* Needed for IE */
        height:0px;
    }
</style>
<script>
    function onLoad()
    {
        FreezeGridViewHeader('GridView1','WrapperDiv');
    }


    function FreezeGridViewHeader(gridID,wrapperDivCssClass)
    {
        /// <summary>
        ///   Used to create a fixed GridView header and allow scrolling
        /// </summary>
        /// <param name="gridID" type="String">
        ///   Client-side ID of the GridView control
        /// </param>
        /// <param name="wrapperDivCssClass" type="String">
        ///   CSS class to be applied to the GridView's wrapper div element.
        ///   Class MUST specify the CSS height and width properties.
        ///   Example: width:800px;height:400px;border:1px solid black;
        /// </param>
        var grid = document.getElementById(gridID);
        if (grid != 'undefined')
        {
            grid.style.visibility = 'hidden';
            var div = null;
            if (grid.parentNode != 'undefined')
            {
                //Find wrapper div output by GridView
                div = grid.parentNode;
                if (div.tagName == "DIV")
                {
                    div.className = wrapperDivCssClass;
                    div.style.overflow = "auto";
                }
            }
            //Find DOM TBODY element and remove first TR tag from
            //it and add to a THEAD element instead so CSS styles
            //can be applied properly in both IE and FireFox
            var tags = grid.getElementsByTagName('TBODY');
            if (tags != 'undefined')
            {
                var tbody = tags[0];
                var trs = tbody.getElementsByTagName('TR');
                var headerHeight = 8;
                if (trs != 'undefined')
                {
                    headerHeight += trs[0].offsetHeight;
                    var headTR = tbody.removeChild(trs[0]);
                    var head = document.createElement('THEAD');
                    head.appendChild(headTR);
                    grid.insertBefore(head, grid.firstChild);
                }
                //Needed for Firefox
                tbody.style.height =
                  (div.offsetHeight -  headerHeight) + 'px';
                tbody.style.overflowX = "hidden";
                tbody.overflow = 'auto';
                tbody.overflowX = 'hidden';
            }
            grid.style.visibility = 'visible';
        }
    }
</script>


很久以前就已经回答过类似的问题

在asp.net中冻结网格 [ ^ ]

您可以在此处找到更多信息 [ ^ ]
Already answered for similar question long time ago

Freeze grid in asp.net[^]

You can find more here[^]


这篇关于使用firefox在asp.net中的freeZe gridview标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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