小编jme*_*te1的帖子

GridView列宽 - 如何停止"收缩适合"行为

我目前正在尝试使用冻结标头实现GridView.我已经使用在线找到的javascript冻结了标题.这是代码:

    var GridId = "<%=dgContacts.ClientID %>";
    var ScrollHeight = 180;
    var ScrollWidth = 700;
    window.onload = function () {
        enablePostLog();
        var grid = document.getElementById(GridId);
        var gridWidth = grid.offsetWidth;
        var headerCellWidths = new Array();
        for (var i = 0; i < grid.getElementsByTagName("TH").length; i++) {
            headerCellWidths[i] = grid.getElementsByTagName("TH")[i].offsetWidth;
        }
        grid.parentNode.appendChild(document.createElement("div"));
        var parentDiv = grid.parentNode;

        var table = document.createElement("table");
        for (i = 0; i < grid.attributes.length; i++) {
            if (grid.attributes[i].specified && grid.attributes[i].name != "id") {
                table.setAttribute(grid.attributes[i].name, grid.attributes[i].value);
            }
        }
        table.style.cssText = grid.style.cssText;
        table.style.width …
Run Code Online (Sandbox Code Playgroud)

javascript css gridview width

3
推荐指数
1
解决办法
3956
查看次数

标签 统计

css ×1

gridview ×1

javascript ×1

width ×1