惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LINUX DO - 最新话题
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
PCI Perspectives
PCI Perspectives
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
H
Heimdal Security Blog
S
Security @ Cisco Blogs
N
News | PayPal Newsroom
J
Java Code Geeks
罗磊的独立博客
Security Archives - TechRepublic
Security Archives - TechRepublic
N
News and Events Feed by Topic
V
V2EX
WordPress大学
WordPress大学
Google Online Security Blog
Google Online Security Blog
N
News and Events Feed by Topic
www.infosecurity-magazine.com
www.infosecurity-magazine.com
月光博客
月光博客
AI
AI
小众软件
小众软件
The GitHub Blog
The GitHub Blog
MongoDB | Blog
MongoDB | Blog
A
Arctic Wolf
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
美团技术团队
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
Tailwind CSS Blog
S
Schneier on Security
博客园 - 三生石上(FineUI控件)
F
Full Disclosure
B
Blog RSS Feed
Forbes - Security
Forbes - Security
S
SegmentFault 最新的问题
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
人人都是产品经理
人人都是产品经理
云风的 BLOG
云风的 BLOG
Jina AI
Jina AI
Cisco Talos Blog
Cisco Talos Blog
U
Unit 42
Project Zero
Project Zero
H
Hacker News: Front Page
Y
Y Combinator Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
The Cloudflare Blog
大猫的无限游戏
大猫的无限游戏
S
Secure Thoughts
The Hacker News
The Hacker News
Microsoft Azure Blog
Microsoft Azure Blog

博客园 - lrary

JavaScript经典技巧 - lrary - 博客园 动态添加ASP.NET控件并绑定处理事件一例 - lrary - 博客园 脚本收藏 - lrary - 博客园 一些sql语句的详细解释[转] 特殊的DataGrid的绑定 - lrary - 博客园 检验密码强度的JS类 - lrary - 博客园 数据库设计规范 V2.0 SQL语句特---殊统计(1) DataGrid 多行 DataGrid怎么产生一个分类的题头 AJAX 在.net的应用 sql怎么使用外连接 Asp.NET程序中常用的三十三种代码 检测含有中文字符串的实际长度 根据区位得到汉字拼音首字母(c#) 认识ASP.NET配置文件Web.config Asp.net(C#)实现验证码功能 给Repeater、Datalist和Datagrid增加自动编号列 查找和统计页面上控件
纯脚本搞掂DataGrid表表头不动,表身滚动。(转摘) - lrary - 博客园
lrary · 2006-05-16 · via 博客园 - lrary

纯脚本搞掂DataGrid表表头不动,表身滚动。(转摘)

纯脚本搞掂DataGrid表表头不动,表身滚动。

先看效果:

孟子以前也做过这事,不过他的方法前台后台都要弄,还是VB的(^-^),好像也不支持像我的自动生成列的DataGrid,所以还是自己动手,纯脚本搞掂,其实很简单,就几行:

  function ScrollDataGrid() 
        

            
var tb = document.getElementById("tbHeader"); 
            
var dg = document.getElementById("dgSearchResult"); 
             
            
if(dg!= null
            
{     
                
var dv = document.getElementById("dvBody"); 
                
var th = dg.rows[0]; 
                
for(var i = 0 ; i < th.cells.length;i++
                    th.cells[i].width 
= th.cells[i].clientWidth; 
                
var tr = th.cloneNode(true); 
                 
                
//tr.applyElement(tb); 
                tb.createTHead(); 
                
var tbh = tb.tHead; 
                tbh.appendChild(tr); 
                tr 
= tbh.rows[0]; 
                
var td = tr.insertCell(); 
                td.style.width 
= 19
                td.width 
= 19
                td.innerHTML 
= tr.cells[0].innerHTML; 
                th.style.display 
= 'none'; 
                
if(dg.scrollHeight < 300 ) 
                    dv.style.height 
= dg.scrollHeight * 1 + 2
                 
                 
            }
 

 

<table width="100%" border="0" id="tbHeader" cellpadding="4" cellspacing="0"> 
                                        
</table> 
                                        
<div style="OVERFLOW-Y: scroll; HEIGHT: 300px" id="dvBody"> 
                                            
<asp:datagrid id="dgSearchResult" style="BORDER-COLLAPSE: collapse" runat="server" Width="100%" CellPadding="4" DataKeyField="编号" BorderWidth="1px" BorderStyle="Solid" BorderColor="RoyalBlue" GridLines="None"> 
                                                
<SelectedItemStyle ForeColor="SlateGray"></SelectedItemStyle> 
                                                
<ItemStyle VerticalAlign="Middle"></ItemStyle> 
                                                
<HeaderStyle HorizontalAlign="Center"></HeaderStyle> 
                                                
<Columns> 
                                                    
<asp:ButtonColumn Text="选择" HeaderText="&lt;font face=webdings&gt;6&lt;/font&gt;" CommandName="Delete"> 
                                                        
<HeaderStyle Wrap="False" Width="40px"></HeaderStyle> 
                                                        
<ItemStyle Wrap="False" HorizontalAlign="Center"></ItemStyle> 
                                                        
<FooterStyle Wrap="False"></FooterStyle> 
                                                    
</asp:ButtonColumn> 
                                                
</Columns> 
                                            
</asp:datagrid></div> 
 

posted on 2006-05-16 09:36  lrary  阅读(419)  评论(0)    收藏  举报