GridView(table) 滚动条 固定表头、列

本文介绍了如何在ASP.NET的GridView中实现滚动条时保持表头和列固定,提供了一种CSS样式解决方案,适用于W3C标准。内容包括相关CSS类的定义和HTML结构,可用于实现表格在滚动时保持表头和列位置不变。

开始在网上找了资料挺高兴,但是放在自己的ASP.NET代码中却产生奇怪的效果。经过测试摸索终于全部解决了,贴出来与大家一起分享。

 解决了声明W3C标准时滚动条的问题

 

适易工作流、项目管理平台、基于XML配置的快速信息管理系统开发平台

试用及下载地址:http://121.18.78.216

联系人:贾世义

电话:15832292227 QQ: 914734554 邮箱:jsyhello@gmail.com

谢谢您阅读,真诚希望能交流合作

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1"><title>
 GridView(table)固定表头、列 贾世义 http://121.18.78.216/
</title>
    <style type="text/css">
.list
{

/*改为 100% 并将overflow-x:hidden 则不显示横向滚动条*/
 width:390px;
 overflow-x:auto;

/*改为 100% 并将overflow-y:hidden 则不显示纵向滚动条*/
 height:120px;
 overflow-y:auto;
    clear: both;
    border: 1px solid #eeeeee;
/*很重要 没有此项固定的行列将漂起来 */

    position: relative;
    z-index:3;
}

/*固定列 样式*/
.scrollRowThead
{
    position: relative;
    table-layout: fixed;
/*利用offsetParent 在W3C标准下获取的是table 而不是div 所以需要根据层级直接写*/
    left: expression(this.parentElement.parentElement.parentElement.parentElement.parentElement.scrollLeft);
    background-color:#eeeeee;
    z-index:0;
}

/*固定标题 样式*/
.scrollColThead {
 position: relative;
    table-layout: fixed;

/*利用offsetParent 在W3C标准下获取的是table 而不是div 所以需要根据层级直接写*/
    top: expression(this.parentElement.parentElement.parentElement.parentElement.scrollTop);
    background-color:#eeeeee;
    z-index:1;
}

/*交叉 向上提 不然会被覆盖不好看*/
.scrollCR {
     z-index:2;
}
    </style>
</head>
<body style="font-size: 12px">
    <form name="form1" method="post" action="Test.aspx" id="form1">
<div>
    <div class="list">
        <span>
 <table cellspacing="0" cellpadding="3" rules="all" border="1" id="GridView1" style="background-color:White;border-color:#EEEEEE;border-width:1px;border-style:None;font-size:12px;border-collapse:collapse;">
  <tr class="scrollColThead" class="scrollColThead" style="background-color:#EEEEEE;font-weight:bold;">
   <th class="scrollRowThead scrollCR" nowrap="nowrap" scope="col">ID</th><th class="scrollRowThead scrollCR" nowrap="nowrap" scope="col">Name</th><th nowrap="nowrap" scope="col">Iflag</th><th nowrap="nowrap" scope="col">DepID</th><th nowrap="nowrap" scope="col">Pwd</th><th nowrap="nowrap" scope="col">email</th><th nowrap="nowrap" scope="col">Tel</th><th nowrap="nowrap" scope="col">Sn</th><th nowrap="nowrap" scope="col">startdate</th><th nowrap="nowrap" scope="col">WorkGradeID</th><th nowrap="nowrap" scope="col">IsEffort</th>
  </tr><tr>
   <td class="scrollRowThead" nowrap="nowrap">admin</td><td class="scrollRowThead" nowrap="nowrap">管理员</td><td nowrap="nowrap">1</td><td nowrap="nowrap">1007</td><td nowrap="nowrap">admin</td><td nowrap="nowrap">jsyhello76@126.com</td><td nowrap="nowrap">请勿动</td><td nowrap="nowrap">0</td><td nowrap="nowrap">2011-4-5 0:00:00</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">1</td>
  </tr><tr>
   <td class="scrollRowThead" nowrap="nowrap">jiashiyi</td><td class="scrollRowThead" nowrap="nowrap">贾世义</td><td nowrap="nowrap">1</td><td nowrap="nowrap">1007</td><td nowrap="nowrap">admin</td><td nowrap="nowrap">jsyhello@gmail.com</td><td nowrap="nowrap">15832292227</td><td nowrap="nowrap">0</td><td nowrap="nowrap">2011-4-5 0:00:00</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">1</td>
  </tr><tr>
   <td class="scrollRowThead" nowrap="nowrap">jiazhichen</td><td class="scrollRowThead" nowrap="nowrap">贾子宸</td><td nowrap="nowrap">1</td><td nowrap="nowrap">1007</td><td nowrap="nowrap">admin</td><td nowrap="nowrap">jsyhello@163.com</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">&nbsp;</td>
  </tr><tr>
   <td class="scrollRowThead" nowrap="nowrap">lijingping</td><td class="scrollRowThead" nowrap="nowrap">李建平</td><td nowrap="nowrap">1</td><td nowrap="nowrap">1007</td><td nowrap="nowrap">admin</td><td nowrap="nowrap">jiachen87@126.com</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">&nbsp;</td><td nowrap="nowrap">&nbsp;</td>
  </tr>
 </table>
</span>
    </div>
    </form>
</body>
</html>

 

内容概要:本文围绕“能量-物流耦合+港口综合能源优化”展开研究,提出基于混合整数线性规划(MILP)的优化模型,并利用Matlab实现港口综合能源系统的协同调度与资源配置。研究充分考虑电、热、冷等多种能源形式与货物运输物流之间的耦合关系,通过构建数学模型优化能源的供给、转换、存储及物流调度全过程,旨在降低系统运行成本、提升能源利用效率并增强系统可靠性与韧性。文中详细阐述了模型的构建过程、关键约束条件的设定、目标函数的设计以及求解流程,并通过具体算例进行仿真验证,展示了所提方法在实际应用中的有效性与优越性。; 适合人群:具备一定电力系统、能源管理、运筹优化或交通运输背景,从事相关领域科研或工程应用的研究生、科研人员及技术人员。; 使用场景及目标:①应用于港口、临港工业区、物流园区等多能耦合与物流密集型场景的综合能源系统规划设计;②实现能源系统与物流作业的协同优化调度,提升整体运营的经济性、低碳性与抗干扰能力;③为相关领域的研究者提供完整的Matlab代码实现范例,支持模型复现、性能测试与进一步的功能拓展。; 阅读建议:建议结合文中提供的Matlab代码与模型框架,配合实际案例数据进行仿真调试,深入理解能量流与物流的耦合机制及MILP优化求解过程,可进一步结合YALMIP工具箱或CPLEX求解器进行模型改进与算法创新。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值