JS表头冻结
来源:互联网 发布:淘宝网足球 编辑:程序博客网 时间:2024/04/27 20:33
http://www.toumai.cn/download.asp
JS 文件:
function writeTitleDiv(height,wid)
{
document.write ("<div id='div_title' style='OVERFLOW-Y: hidden; Z-INDEX: 100; OVERFLOW-X: hidden; OVERFLOW: scroll; WIDTH:"+wid+"%; left: 10px; POSITION: absolute; HEIGHT:"+height+"px'>")
}
function writeBodyDiv(top,wid)
{
var width = wid;
var height = document.body.clientHeight - top;
document.write ("<div id='div_table' style='position:absolute; width:"
+width+"%; height:"+height+"px; z-index:1; right:30px; left: 10px; top:"
+top+"px; overflow: scroll;' onscroll='return buildTitle()'>");
}
function buildTitle()
{
div_title.style.posTop =div_table.style.posTop - 1;
div_title.scrollLeft = div_table.scrollLeft;
var maxrowSpan;//td_maxrow.rowSpan
maxrowSpan = maxRowTd.rowSpan;
if(maxrowSpan == null)
{
maxrowSpan = 1;
}
for(var j=0;j<maxrowSpan;j++)
{
for(var i=0;i<table_table.rows(j).cells.length;i++)
{
if(table_title.rows(j).cells(i).offsetWidth < table_table.rows(j).cells(i).offsetWidth)
{
//alert(table_title.rows(j).cells(i).style.posWidth);
if(table_table.rows(j).cells(i).style.width.length == 0)
{
table_title.rows(j).cells(i).style.posWidth = table_table.rows(j).cells(i).offsetWidth;
}
else
{
table_title.rows(j).cells(i).style.width = table_table.rows(j).cells(i).style.width;
}
}
else
{ if(table_title.rows(j).cells(i).style.width.length == 0)
{
table_table.rows(j).cells(i).style.posWidth = table_title.rows(j).cells(i).offsetWidth ;
}
else
{
table_table.rows(j).cells(i).style.width = table_title.rows(j).cells(i).style.width;
}
}
}
}
div_title.style.width = div_table.clientWidth;
}
function killErrors() {return true;}
window.onerror = killErrors;
ASPX文件:
<%@ Page language="c#" Codebehind="FailsummaryDMP.aspx.cs" AutoEventWireup="false" Inherits="Report.Report.DMPL10.failsummaryDMP" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>failsummaryDMP</title>
<meta content="Microsoft Visual Studio .NET 7.1" name=GENERATOR>
<meta content=C# name=CODE_LANGUAGE>
<meta content=JavaScript name=vs_defaultClientScript>
<meta content=http://schemas.microsoft.com/intellisense/ie5 name=vs_targetSchema>
<LINK href="../../../../INC/CSS/style.css" type=text/css rel=stylesheet >
<meta http-equiv=Content-Type content="text/html; charset=big5">
<script language="javascript">
<!--#i nclude file="../../../../INC/JS/Common.js"-->
</script>
</HEAD>
<body language=javascript onresize="return buildTitle();" rightMargin="20" topMargin=5 scroll=no
onload="return buildTitle();">
<form id=Form1 method=post runat="server">
<TABLE id=Title runat="server">
<TR>
<TD noWrap><asp:placeholder id=placeReport_Title
Runat="server"></asp:placeholder></TD></TR></TABLE>
<table>
<tr width="100%">
<td align=right width=100></TD></TR></TABLE></FORM>
<script language="javascript">
writeTitleDiv(50,100);
</script>
<asp:label id=Label_titlesub runat="server" EnableViewState="False"></asp:label>
<script language="javascript">
document.write("</div>");
</script>
<table>
<tr>
<td nowrap id="td1"><asp:label id="Label_Query_Info" runat="server" EnableViewState="False"></asp:label>
</td>
</tr>
</table>
<script language = "javascript">
writeBodyDiv(130,100);
</script>
<asp:label id="lbl_DataTable" runat="server" EnableViewState="False"></asp:label>
<TABLE>
<TR>
<TD>
<asp:PlaceHolder id="placeMessage" Runat="server"></asp:PlaceHolder></TD>
</TR>
</TABLE>
<script language="javascript">
document.write ("</div>");buildTitle();buildTitle();
</script>
</body>
</HTML>
CS:
#region [ Query Info ]
Label_Query_Info.Text = @"<table><tr class = 'tip'><td> </td></tr></table>";
#endregion
#region [ Table Title ]
string tablehead =@"
<table id='table_table' class='haveborder' border='1' bordercolor = '#000000'>
<tr class = 'head'>
<td id = 'maxRowTd' nowrap>Item</td>
<td nowrap>A</td>
<td nowrap>A</td>
<td nowrap>A</td>
<td nowrap>A</td>
<td nowrap>S</td>
<td nowrap>A</td>
<td nowrap>E</td>
<td nowrap>W</td>
</tr>
";
strTable.Append(tablehead);
if(Request.QueryString["Excel"] == null)
{
Label_titlesub.Text = @"<table
id='table_title' class='haveborder' border='1' bordercolor = '#000000' runat='server'>
<tr class = 'head' nowrap>
<td nowrap>Item</td>
<td nowrap>A</td>
<td nowrap>A</td>
<td nowrap>A</td>
<td nowrap>A</td>
<td nowrap>S</td>
<td nowrap>A</td>
<td nowrap>E</td>
<td nowrap>W</td>
</tr></table>";
}
#endregion
- JS表头冻结
- JS实现表头冻结
- 表头冻结
- Table冻结表头
- table表头冻结
- 冻结表头HTML报表制作方法
- Table冻结多行表头
- 一段冻结表头的代码
- 冻结表头HTML报表制作方法
- 关于Web中的冻结表头
- html+jquery 冻结表格表头
- 快逸报表研究-冻结表头
- web DataGridView 冻结表头和列
- PHPExcel冻结(锁定)表头的使用方法
- JS冻结表格
- JS冻结表格
- js对象冻结
- 页面列表数据的表头或者行头冻结的方法
- 重写了PKU2897“Dramatic Multiplications”,AC了,重写后思路很清晰,果然不一样!
- 爱不是一个坚强的理由
- 休息几天吧--放松
- Google对付桥页作弊的方法 - 供百度开发人员参考
- 告别学生时代,开始职业生涯
- JS表头冻结
- 2006-07-27 我又感冒了,我又做噩梦了.
- 通过Windows 2000专业版的注册表来配置系统服务
- 再见了,煤田~~~~
- 图形程序开发人员指南前言
- #ifndef#define#endif的用法(整理)
- 灯泡的故事
- 委托的理解 (抓小偷
- DataGrid显示双层表头