我再ERP的程序上看到过这样的数据统计报表:标题随着横向的滚动条滚动,但是当纵向滚动条滚动的时候,标题是不动的。
怎么样才能做到呢?我用的是VS2005 GridView,我能实现的是:
1。当纵向滚动条滚动时,标题不动。
缺点:当数据字段足够多时要加横向滚动条,因为标题不动,所以会错位。
CSS代码:<style type="text/css" >
.DataGridFixedHeader
{
POSITION: relative;
TOP: expression(this.offsetParent.scrollTop);
BACKGROUND-COLOR:blue;
height:25px;
color:#ffffff;
text-align:center ;
vertical-align:middle;
font-weight:bold;
font-size:13px;
background-color:#5D7B9D;
}
</style>2。能够加纵向和横向滚动条。
缺点:但是标题随纵向滚动条滚动时会看不到。
代码:<style type="text/css" id="print" media="print">
#leftSide, #footerSide {
display:none;
}
</style>
<style type="text/css" >
.Freezing
{
position:relative ;
table-layout:fixed;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}
.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}
</style>以上2种方法均是在GridView加DIV。请教高手,最好能具体点
怎么样才能做到呢?我用的是VS2005 GridView,我能实现的是:
1。当纵向滚动条滚动时,标题不动。
缺点:当数据字段足够多时要加横向滚动条,因为标题不动,所以会错位。
CSS代码:<style type="text/css" >
.DataGridFixedHeader
{
POSITION: relative;
TOP: expression(this.offsetParent.scrollTop);
BACKGROUND-COLOR:blue;
height:25px;
color:#ffffff;
text-align:center ;
vertical-align:middle;
font-weight:bold;
font-size:13px;
background-color:#5D7B9D;
}
</style>2。能够加纵向和横向滚动条。
缺点:但是标题随纵向滚动条滚动时会看不到。
代码:<style type="text/css" id="print" media="print">
#leftSide, #footerSide {
display:none;
}
</style>
<style type="text/css" >
.Freezing
{
position:relative ;
table-layout:fixed;
top:expression(this.offsetParent.scrollTop);
z-index: 10;
}
.Freezing th{text-overflow:ellipsis;overflow:hidden;white-space: nowrap;padding:2px;}
</style>以上2种方法均是在GridView加DIV。请教高手,最好能具体点
http://blog.csdn.net/cpp2017/archive/2007/02/03/1501636.aspx
</div>
<div id="divGridViewBody" style="overflow-y: scroll; height: 200px; width: 580px;">
<asp:GridView ID="gvScrollDemo" runat="server" Font-Size="12px" BackColor="#FFFFFF"
GridLines="Both" CellPadding="4" Width="560">
<HeaderStyle BackColor="#EDEDED" Height="26px" />
</asp:GridView>
</div>
function initGridView()
{
var tbBody = document.getElementById("<%= gvScrollDemo.ClientID %>");
var tbHeader = tbBody.cloneNode(true);
var divHeader = document.getElementById("divGridViewHeader");
for(i = tbHeader.rows.length -1; i > 0;i--)
{
tbHeader.deleteRow(i)
}
tbBody.deleteRow(0)
divHeader.appendChild(tbHeader)
}
http://www.codeproject.com/KB/webforms/FreezePaneDatagrid.aspx
不是,我的意思是说我在VS2005 上用B/S模式(C# Gridview) 实现ERP(C/S)上那个滚动的功能。